Mathew
Mathew

Reputation: 1430

selecting with a column being one of two possible values

I have a table called "people" with a column named "name". I would like to select all rows where the name is "bob" or "john". I have tried the following and many variants of it, none of which work. How can I do this correctly?

select * from people where name is bob or john;

Thanks

Upvotes: 0

Views: 1847

Answers (1)

user330315
user330315

Reputation:

To compare a column with a value you need to use = not IS

select * 
from people 
where name = 'bob' 
  or name = 'john';

Alternatively you can use the IN operator.

select * 
from people 
where name IN ('bob','john');

Note that string comparison is case-sensitive in SQL. So the above will not return rows where the name is Bob or John

Upvotes: 2

Related Questions