Jump to content

Silly question? Where clause


TEENFRONT

Recommended Posts

i need to select from database where id= 1, 2, 3, 4, 5.

 

How do i do that? all the code snippets i find online and tuts just do WHERE id=1    but i need to specifically select a few ids. if i use AND, it returns nothing?

 

im sure its uber simple but i cannot find anything for the life of me..i tried searching around but i end up with the simple where clause and not multiple where lol.

 

hoping you can help :)

Link to comment
https://forums.phpfreaks.com/topic/134860-silly-question-where-clause/
Share on other sites

The reason why AND does not work is that a column can only have a single value at any time. Writing: WHERE id=1 and id=7 ... is asking for rows WHERE id=1 and id=7... at that same time and that cannot exist. You would actually need to use OR, which is logically the same as the IN() function that laPistola posted.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.