Photobrad.com Posted June 17, 2007 Share Posted June 17, 2007 I'm having trouble with the syntax on a query string, and haven't been able to find any posts or tutorials that seem to address this specific type of query. I have a table named "items" with a field for "name" In the "name" field, I have several different entries (actual data), including John, Mark, Sue, Brian, Lucy, etc. In the specific page I'm building, I want to query the database and return the data for more than one person, but not everyone. It seems the query string should be: $query="SELECT * FROM items WHERE name='Brian' AND name='Sue' ORDER BY name ASC"; However I get errors. If I remove the "AND name='Sue'" it returns data for Brian just fine, and if I remove "name='Brian' AND" it returns data for Sue, but I can't get it to return the data for both of them. Am I missing something obvious? Link to comment https://forums.phpfreaks.com/topic/55914-solved-query-string-with-multiple-values-in-one-table/ Share on other sites More sharing options...
pocobueno1388 Posted June 17, 2007 Share Posted June 17, 2007 Instead of using AND, try using OR. <?php $query = "SELECT * FROM items WHERE name='Brian' OR name='Sue' ORDER BY name ASC"; ?> Link to comment https://forums.phpfreaks.com/topic/55914-solved-query-string-with-multiple-values-in-one-table/#findComment-276180 Share on other sites More sharing options...
Photobrad.com Posted June 17, 2007 Author Share Posted June 17, 2007 See... I knew it was simple. Worked like a charm! Thanks! Link to comment https://forums.phpfreaks.com/topic/55914-solved-query-string-with-multiple-values-in-one-table/#findComment-276363 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.