Question

Is it possible to search for an array of numbers in a comma separated column?

I know that this is possible

SELECT * FROM products WHERE FIND_IN_SET('1', '1,3,5') > 0

But is this possible too?

SELECT * FROM products WHERE FIND_IN_SET('1,2', '1,3,5') > 0

If 1 or 2 be in the column it should return > 0

if you know another method just let me know

thank you

Était-ce utile?

La solution

No, but you can use find_in_set multiple times

SELECT * FROM products
WHERE FIND_IN_SET(1, '1,3,5') > 0
   OR FIND_IN_SET(2, '1,3,5') > 0
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top