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? Quote 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) . ")"; Quote Link to comment https://forums.phpfreaks.com/topic/202013-this-should-be-simple/#findComment-1059365 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.