Can I select more than 1 row in a database with varying identifiers?
SELECT * FROM `views` WHERE `img_id` =52 and where 'img_id' =123 LIMIT 0 , 30
This should return all rows where above mentioned image ids occur.
In some cases this may be looking for 10 - 20 identifiers
This is the query you probably want to write:
SELECT *
FROM `views`
WHERE `img_id` = 52 or img_id = 123
LIMIT 0 , 30
This removes the second where
, which is syntactically incorrect. It also removed the single quotes from image_id
, which cause that to be treated as a string constant. Only use single quotes for string constants. Never use them for identifiers for tables name and column names.
By the way, you can more simply write this as:
SELECT *
FROM `views`
WHERE img_id in (52, 123)
LIMIT 0 , 30;