I am looking to write an efficient query to match a comma separated list of integers to match on a comma separated column.
The tables would look like:
Words
- id
- word
- versionId ( comma separated, ex: 1,3 )
I want a where clause where I get all words that are in version 1 and 4. Is there an efficient way of doing this on a table with 20,000+ words?
I am trying to use FIND_IN_SET( $versions, words.versionId )
where $versions
is a comma separated list, but that does not work. The other solution I saw online was to make many FIND_IN_SET(..)
clauses and combine them with an OR
, but I dont see that scaling very well. Am I missing a solution?