MySQL String Comparison with Percent Output (Position Very Important

richarddepth

New Member
I am trying to compare two entries of 6 numbers, each number which can either can be zero or 1 (i.e 100001 or 011101). If 3 out of 6 match, I want the output to be .5. If 2 out of 6 match, i want the output to be .33 etc. Note that position matters. A match only occurs when both entries have a 1 in the first position, both have a 0 in the second position etc.Here are the SQL commands to create the table\[code\]CREATE TABLE sim(sim_key int, string int);INSERT INTO sim (sim_key, string)VALUES (1, 111000);INSERT INTO sim (sim_key, string)VALUES (2, 101101);\[/code\]My desired output to compare the two strings, which share 50% of the characters, and output 50%.Is it possible to do this sort of comparison in SQL? Thanks in advance
 
Top