PHP Nubsauce Posted July 23, 2008 Share Posted July 23, 2008 Hey Guys, I always refer to php and sql manuals for easy answers - but this one i can't seem to find fast enough. Can you tell me how to write this script? I've tried $links = @mysql_query("SELECT * FROM ".$mysql_pretext."_users WHERE ID = '1' AND '2'"); as well as $links = @mysql_query("SELECT * FROM ".$mysql_pretext."_users WHERE ID = '1 AND 2'"); and neither worked. Any suggestions? I'm trying to pull only the users with ID 1 and 2 Thanks Nubsauce Link to comment https://forums.phpfreaks.com/topic/116241-an-and-in-my-where/ Share on other sites More sharing options...
GingerRobot Posted July 23, 2008 Share Posted July 23, 2008 The syntax you're looking for is: ...WHERE ID = 1 OR ID = 2 You don't need quotes around integers. Alternatively, if you had a list of id's, you'd be better off using an IN clause: ...WHERE ID IN (1,2,3,4,5) Link to comment https://forums.phpfreaks.com/topic/116241-an-and-in-my-where/#findComment-597696 Share on other sites More sharing options...
Jove Posted July 23, 2008 Share Posted July 23, 2008 you have to write your condition like this: SELECT FROM ... WHERE field1='1' AND field2='2' but I think you want to do something like this: SELECT FROM ... WHERE field1='1' OR field1='2' Link to comment https://forums.phpfreaks.com/topic/116241-an-and-in-my-where/#findComment-597697 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.