Skip to content

Latest commit

 

History

History
24 lines (16 loc) · 675 Bytes

FIND_IN_SET.md

File metadata and controls

24 lines (16 loc) · 675 Bytes

Find an element in a delimited list

You can search a comma-delimited list in SQL by using FIND_IN_SET. Although its considered poor design, it is possible to nest values in a field as a comma delimited list:

fruit_table

fruit tags
apple red,delicious
banana yellow

You can query tags using FIND_IN_SET:

SELECT * FROM fruit_table WHERE FIND_IN_SET('delicious', tags)

The above query will return

fruit tags
apple red,delicious

Normally you would want to normalize this kind of data, but it may be convenient in some instances.