1

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 :)

1

1 Answer 1

3

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')");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.