P Kishor <punk.k...@gmail.com> wrote: > I want the values of ‘a’ for which ‘b’ = 3 AND ‘b’ = 4 (This is just > an example. In reality, b could be any set of numbers, not just two > numbers). To illustrate -- > sqlite> SELECT * FROM foo WHERE b = 3; > a b > ---------- ---------- > 2 3 > 3 3 > 5 3 > sqlite> SELECT * FROM foo WHERE b = 4; > a b > ---------- ---------- > 3 4 > 5 4 > > So, I really want only the following rows > 3 3 > 5 3 > 3 4 > 5 4
select * from foo where a in (select a from foo where b=3 intersect select a from foo where b=4) and b in (3, 4); Or something like this - it scales to longer lists: select * from foo f1 where (select count(*) from (select distinct b from foo f2 where f1.a = f2.a and f2.b in (...) )) = length_of_b_list and b in (...); Igor Tandetnik _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users