Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.