Hi All,
I have a SQL query like this (I have tried to break the problem down
to simplify it),
select rowid from table where name in ('a', 'b', 'd') group by rowid
Here is an example of data in the table
rowid name
1 a
1 b
1 c
1 d
2 a
2 b
That query gives back row 1, and 2. But that is not what I want it to
do.
What I actually want it to do is give me back rowids of records which
have 'all' of the items in the 'name in ('a', 'b', 'd')' clause.
E.g. I want it to return back rowid 1 only because it has a row with
a, b, and d, but I don't want it to return back 2 because it doesn't
have a row with the name d (which is in my 'name in ('a', 'b', 'd')'
clause)
A bit obscure I know. Hopefully you can all follow. Please help.
I have a SQL query like this (I have tried to break the problem down
to simplify it),
select rowid from table where name in ('a', 'b', 'd') group by rowid
Here is an example of data in the table
rowid name
1 a
1 b
1 c
1 d
2 a
2 b
That query gives back row 1, and 2. But that is not what I want it to
do.
What I actually want it to do is give me back rowids of records which
have 'all' of the items in the 'name in ('a', 'b', 'd')' clause.
E.g. I want it to return back rowid 1 only because it has a row with
a, b, and d, but I don't want it to return back 2 because it doesn't
have a row with the name d (which is in my 'name in ('a', 'b', 'd')'
clause)
A bit obscure I know. Hopefully you can all follow. Please help.
Comment