steveangelis Posted August 15, 2009 Share Posted August 15, 2009 I am doing a simple query from a database, nothing fancy, select * from table, except the field I am pulling data from has multiple items in it like this: 3,5,7,9,10 etc. Each of these are in one field in the database. How I make the query select each and every one of those, or just one instead of them all for that matter? Quote Link to comment https://forums.phpfreaks.com/topic/170427-solved-query-error/ Share on other sites More sharing options...
smerny Posted August 15, 2009 Share Posted August 15, 2009 you could use the explode function to get them separated into different elements of an array http://us2.php.net/explode Quote Link to comment https://forums.phpfreaks.com/topic/170427-solved-query-error/#findComment-898997 Share on other sites More sharing options...
wildteen88 Posted August 15, 2009 Share Posted August 15, 2009 Use the MySQL IN() function in your WHERE clause. Example $ids = '3,5,7,9,10'; $query = "SELECT * FROM table WHERE id IN($ids)"; $result = mysql_query($query); Quote Link to comment https://forums.phpfreaks.com/topic/170427-solved-query-error/#findComment-898999 Share on other sites More sharing options...
steveangelis Posted August 15, 2009 Author Share Posted August 15, 2009 Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/170427-solved-query-error/#findComment-899000 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.