Answer the question
In order to leave comments, you need to log in
Is it possible to select records in MySQL by comparing id arrays?
Hello.
I have a field in the table for numbers separated by commas, for example, 1,2,3 (displaying the days of the week).
The "IN" operator selects by matching the first digit.
For example, if you specify " IN (1,2) ", it will select fields that start with 1 (one) SELECT * FROM objects WHERE week_day IN (1,2);
And if you specify "IN (2,3)" (does not start with one), it will give an error, although 2 and 3 match .I SELECT * FROM objects WHERE week_day IN (2,3);
would be grateful for a hint on how to solve this problem and make a selection based on the coincidence of any digits.
Answer the question
In order to leave comments, you need to log in
IN is for comparing against the result of a subquery: https://dev.mysql.com/doc/refman/5.7/en/any-in-som... You need the FIND_IN_SET() function :
This query will find all records that have 2 in the week_day field.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question