Reputation: 75
I'm trying to select with the IN operator in postgreSQL.
When I write:
select name from table where name = 'Eastway'
or
select name from table where name like '%Oxford%'
then I have multiple results but
select name from table where name in ('Eastway', '%Oxford%')
does not return any value.
What am I doing wrong? And apologies for newbie question.
Upvotes: 1
Views: 105
Reputation: 1269773
You can use or
for this. Or a regular expression:
select name
from table
where name ~ '(^Eastway$)|Oxford';
Upvotes: 0
Reputation: 48197
LIKE
is a regular expresion comparasion
=
is exact match
Your IN
is equivalent to name ='Eastway' OR name = '%Oxford%'
But if you say on your first query you get multiple result. On your IN
version should also have some result as well. The rows where name ='Eastway'
Upvotes: 2