Link to home
Start Free TrialLog in
Avatar of rgb192
rgb192Flag for United States of America

asked on

mysql comparision

using mysql
is there a way
to measure how similar two varchar columns are
Avatar of johanntagle
johanntagle
Flag of Philippines image

can you elaborate on your comparison criteria?
Avatar of rgb192

ASKER

Text string

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;
Avatar of rgb192

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
Please post complete information so that we can help you better.  In this case - can you post your complete SQL?
Avatar of rgb192

ASKER

comparing fields from the same column

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.
Avatar of rgb192

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;
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.
Avatar of rgb192

ASKER

I am using linux for this
ASKER CERTIFIED SOLUTION
Avatar of johanntagle
johanntagle
Flag of Philippines image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rgb192

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'
Avatar of rgb192

ASKER

thanks

I will look into comparison further