How to select id's that equals to two values, like id='1,2'
here is what I have:
mysql_query("SELECT * FROM menus WHERE active='1' AND lock=('1' ,'3') ") or die (mysql_error());
i'm new to mysql
Try this:
mysql_query("SELECT * FROM menus WHERE active='1' AND lock IN (1 ,3) ") or die (mysql_error());
or this:
mysql_query("SELECT * FROM menus WHERE active='1' AND (lock = 1 OR lock = 3 ") or die (mysql_error());
You would use the IN
keyword.
So the SQL statement would be:
SELECT * FROM menus WHERE active='1' AND lock IN ('1', '3')
Don't forget to index things kids!
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.