tags:

views:

44

answers:

2

Totally out of ideas here, could be needing a simple solution.

Basically my desired query is :

SELECT * FROM table WHERE id = 3,4

I want to select only the row which has ID 3 and 4, or maybe name "andy" and "paul"

Thank you very much for the answer

+6  A: 

Try or:

WHERE id = 3 or id = 4

Or the equivalent in:

WHERE id in (3,4)
Andomar
And there in maybe a faster expression between those two solutions, but "WHERE id in (3,4)" is the most readable.
jwinandy
thanks, i end up using the first method. It didn't work at first because I used AND... lol . Is it possible to use LIKE in there? I mean WHERE name in ('%P%', '%A') will generate Paul, Peter, Andy, Ann
Henson
@Henson - you can use LIKE as "WHERE name like 'P%' or name like 'A%' "
Sachin Shanbhag
@Henson: LIKE would work with OR, but not with IN. For example `where name like 'A%' or name like 'B%'`
Andomar
+2  A: 

Try this -

 select * from table where id in (3,4) or [name] in ('andy','paul');
Sachin Shanbhag