Search code examples
mysqlselectwhere-clausefind-in-set

MySQL multiple results with find in set of values


I need to get multiple rows with articles where the article IDs are in the list below. (in the string list)

SELECT id, title FROM articles WHERE FIND_IN_SET(id, "1,2,3,4,5,9,25");

How to do that correctly?


Solution

  • Try:

    SELECT id, title 
    FROM articles 
    WHERE FIND_IN_SET(id, '1,2,3,4,5,9,25') <> 0