Using FIND_IN_SET to filter Multi-Value SQL fields Print

  • 6

The FIND_IN_SET string function is an amazing little tool that can save you time and headache by allowing you to compare a value against a comma-separated list. 

SELECT *
FROM `myTable`
WHERE FIND_IN_SET('david', `myTable`.`friends`) > 0

The FIND_IN_SET function returns the pointer of the first instance of "david" found in the comma-separated string "friends", and zero if nothing is found.

Was this answer helpful?

« Back