Jump to content

Archived

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

Canman2005

Multiple ID number query

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

Share this post


Link to post
Share on other sites
Try something like:
[code]
$query=MYSQL_QUERY("SELECT * FROM order WHERE id IN ( $idnums )");
[/code]

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

×

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.