rgb192
asked on
mysql comparision
using mysql
is there a way
to measure how similar two varchar columns are
is there a way
to measure how similar two varchar columns are
can you elaborate on your comparison criteria?
ASKER
Text string
Word1 word2 word3
Word2 word2 word2
What is numerical similarly percentage.
Or what are possible mysql functions
Word1 word2 word3
Word2 word2 word2
What is numerical similarly percentage.
Or what are possible mysql functions
Okay the only thing built-in to MySQL that you can use is the full-text functions. Not sure if that will satisfy your requirement but see http://dev.mysql.com/doc/refman/5.1/en/fulltext-natural-language.html. Basically, assuming column1 is the one with the full-text index, you should be able to do something like:
SELECT column1, column2, MATCH (column1)
AGAINST (column2 IN NATURAL LANGUAGE MODE) AS score
FROM tablename;
SELECT column1, column2, MATCH (column1)
AGAINST (column2 IN NATURAL LANGUAGE MODE) AS score
FROM tablename;
ASKER
Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NATURAL LANGUAGE MODE) AS score
FROM table' at line 2
FROM table' at line 2
Please post complete information so that we can help you better. In this case - can you post your complete SQL?
ASKER
comparing fields from the same column
field1='hello, how are you'
field2='very different'
field3='hi, how are you'
field4='another string
field1='hello, how are you'
field2='very different'
field3='hi, how are you'
field4='another string
You gave me an error message you encountered when you ran a query - I asked for that complete query, not the data you are running it on.
ASKER
I ran this query and substituted my table and column name
query:
SELECT column1, column2, MATCH (column1)
AGAINST (column2 IN NATURAL LANGUAGE MODE) AS score
FROM tablename;
query:
SELECT column1, column2, MATCH (column1)
AGAINST (column2 IN NATURAL LANGUAGE MODE) AS score
FROM tablename;
ok sorry but it looks like MySQL won't accept a column name as a parameter in AGAINST(). You will have to make a script that reads each row and runs that full-text function for each. Based on your previous questions I participated in you are on Windows, and I unfortunately cannot help you make a script on that platform.
ASKER
I am using linux for this
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NATURAL LANGUAGE MODE) AS score
what do I put for 'very different'
what do I put for 'very different'
ASKER
thanks
I will look into comparison further
I will look into comparison further