Jump to content

Multiple ID number query


Canman2005

Recommended Posts

Hi all

I have some id numbers stored in a sql database under a field called "idnums", for example, one of my rows stores id numbers in field "idnums" in the following format

1,5,7,17

each number is a id number in another table.

I insert the id numbers from a multiple selection list on a form using the 'join' function.

I then have a php query which looks like

[code]$query=MYSQL_QUERY("SELECT * FROM order");[/code]

I want to be able to select just the id numbers from the table "orders" that are stored in the "idnums" field, I thought I could do

[code]$query=MYSQL_QUERY("SELECT * FROM order WHERE id = $idnums");[/code]

but it doesnt seem to be able to do that, how could I get it to do this?

Any help would be ace

Thanks in advance

Ed
Link to comment
Share on other sites

[!--quoteo(post=364483:date=Apr 13 2006, 06:05 PM:name=Honoré)--][div class=\'quotetop\']QUOTE(Honoré @ Apr 13 2006, 06:05 PM) [snapback]364483[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Try something like:
[code]
$query=MYSQL_QUERY("SELECT * FROM order WHERE id IN ( $idnums )");
[/code]
[/quote]
Thank you, worked great
Link to comment
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.