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 Quote Link to comment 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) Quote Link to comment 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' Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.