Jump to content

Pulling Multiple Rows by ID in a Single Query using While Statement


Recommended Posts

Hey, I was wondering if there is a way to pull multiple rows at once using a list of unique identifiers. For example, I want to pull the rows with the IDs of 4,13,91 and 252


I know the WHERE part of this query is incorrect, but I'm putting it to hopefully help you guys understand what I'm looking for.

$result = mysql_query("SELECT * FROM $table WHERE id='4' OR '13' OR '91' OR '252'");
while($row = mysql_fetch_array($result))


Or is the best way simply to do it one query at a time without a while statement? There could be as many as a few dozen records being pulled per page.

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

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

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.