merveilles Posted May 17, 2010 Share Posted May 17, 2010 This is probably really simple.. I have a php array, and right now I'm using foreach to get each item, and look it up in a database. So like... foreach($list as $item){ mysql_query("select id where random = '$item'"); } It seems inefficient to do that if there are like 100 items in the array.. Is there a way I can get each specific id for each item using only one mysql query? Link to comment https://forums.phpfreaks.com/topic/202013-this-should-be-simple/ Share on other sites More sharing options...
trq Posted May 17, 2010 Share Posted May 17, 2010 $sql = "SELECT id FROM tbl WHERE random IN(" . implode(',', $list) . ")"; Link to comment https://forums.phpfreaks.com/topic/202013-this-should-be-simple/#findComment-1059365 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.