I would like to select multiple values in where clause but it is not selecting anything.
This is the select query I have:
'SELECT * FROM table WHERE id IN (4, 5) ORDER BY id desc'
what am I missing?
Based on your comments, the reason that the query is failing is because the column is a varchar
and you are using int
values in your IN
clause. MySQL does not convert the type if you quote the numbers then your query will work with varchar
I would imagine your table has no data with id = 4 or id = 5.
Try
SELECT * FROM table WHERE id = 4
Does that return anything either? I would bet no.
为什么不只是
'SELECT * FROM table WHERE (id = '4' OR id= '5') ORDER BY id desc'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.