Reputation: 33
I am trying to search for multiple rows within a database using the PDO handler, using the WHERE function to search for multiple row/variables. I can successful search for individual items using just one name variable, however I was hoping to search for multiple. This is what I've tried but its not working:
$result=$dbh->prepare("SELECT * FROM hire WHERE name='item1', 'item2", 'item3');
Thank you very much for your help :)
Upvotes: 1
Views: 54
Reputation: 952
If you want to choose from a set of values you can use the IN
selector, like this:
$result=$dbh->prepare("SELECT * FROM hire WHERE name IN('item1', 'item2', 'item3')");
Upvotes: 3