Friday, July 27, 2012

Difference between find_in_set and in MySQL

If you are confused with these functions then there is short explanation

They are both used for matching a single value again comma separated multiple values

IN: Works when you are looking for database/column value against commas separated list
e.g. WHERE id IN (1,2,3)

FIND_IN_SET: Works the other way around i.e. when you are looking for a single values against a comma separated list stored in a column
e.g. WHERE FIND_IN_SET('name',namesColumn)
where names is a column having value like ('john,paul,richard')

No comments:

Post a Comment