Search code examples
mysqlrubysequelsequelpro

MYSQL IN only returning first row


I have read several posts about similar issues but all of them were problems in the code while mine even occurs in the mysql sequel console.

my query: SELECT * FROM users WHERE id IN ("1,2") ORDER BY id DESC

My Users table currently contains two users - one with id 1 and the other one with id 2 so actually both should be returned. Unfortunately only the first row gets returned


Solution

  • The IN operator does not parse strings, leave out the double quotes:

    SELECT * FROM users WHERE id IN (1,2) ORDER BY id DESC