bow-viper1 Posted January 11, 2011 Share Posted January 11, 2011 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)) { echo($row['name']); } 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 https://forums.phpfreaks.com/topic/224097-pulling-multiple-rows-by-id-in-a-single-query-using-while-statement/ Share on other sites More sharing options...
BlueSkyIS Posted January 11, 2011 Share Posted January 11, 2011 assuming id is a numeric field: $sql = "SELECT * FROM $table WHERE id IN (4, 13, 91, 252)"; Link to comment https://forums.phpfreaks.com/topic/224097-pulling-multiple-rows-by-id-in-a-single-query-using-while-statement/#findComment-1157965 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.