Jump to content

Select values


dreamwest

Recommended Posts

Im trying to select an array of rows. I need to select all rows with different ids:

 

id | name

 

234 | name1

3    |name2

125  |name3

4  |name4

 

$query = "SELECT * FROM table WHERE id=(4,125) and  approve=1 ";

 

So im selecting everything from row 4 and 125....but syntax error

I cant think how to do it..

 

Link to comment
https://forums.phpfreaks.com/topic/160344-select-values/
Share on other sites

It won't cause problems.  But in SQL it's probably "more" correctly to use OR instead of ||

 

$query = "SELECT * FROM table WHERE (id=4 OR id=125) and  approve=1 ";

 

The IN( ... ) method is probably easier to code in PHP as well with arrays and implode.

Link to comment
https://forums.phpfreaks.com/topic/160344-select-values/#findComment-846155
Share on other sites

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.