In post-post it seems to be possible to split a line by delimiters and get an array suitable for the IN operator.

And how can you do this in mysql? Those. you need it to work:

where id IN ("1,2,3,4") 
  • one
    If your data is stored in this form, it is necessary to normalize the database, and not to work in this way. - etki
  • one
    The first soap should not be how to do it, but how to avoid it. - Yura Ivanov

2 answers 2

There should be no problem with this in mysql. Only you, in your example, for nothing took all the id in some quotes, it will not work like that, they are perceived as one line.

 SELECT * FROM tbl_name WHERE id IN ("2","19","20"); 

and for numbers you can even without quotes

 SELECT * FROM tbl_name WHERE id IN (2,19,20); 
  • As I understand it, he wants to parse it. right in mysql - arg
  • I rephrase the question: there is a line with comma separated values ​​"1,2,3,4", how to break it into separate parts, what to use in the IN operator. - Alex Krass
  • Aah, it seems I understand what the author of the question wants. He already has a string in quotes (obtained from somewhere) and he wants to use it as an array. In Google there are some options (for example, stackoverflow.com/questions/471914/… ). But, IMHO, if you need something like that, then you use SQL incorrectly. In a relational data model, value arrays should not be stored as strings. - MrClon
  • There are still such perversions, just about what is needed: montrealseocompany.com/2012/04/17/… But in general, yes, a very bad idea. - user6550 1:21 pm

You can use the MySQL function FIND_IN_SET :

 where FIND_IN_SET(id, "1,2,3,4")