views:

69

answers:

2

I'm new to MySQL and was wondering; instead of doing

SELECT fields FROM table WHERE name="tim" OR name="bob" OR name="nancy" OR name="john"

If I could do something like

SELECT fields FROM table WHERE (name="tim" OR "bob" OR "nancy" OR "john")
+7  A: 

Use the IN clause:

SELECT fields FROM table WHERE name IN ("tim", "bob", "nancy", "john");
BoltClock
Thank you so much! Very simple!
Bubby4j
+3  A: 

You can do like -

SELECT fields FROM table WHERE name in("tim","bob","nancy","john")
Sadat
Thank you too, sorry you weren't first, I'll up your answer anyways.
Bubby4j
No prob, @BoltClock was 30sec ahead of me :). He did better off course.
Sadat