Suppose I have the following two tables

foo:
10 | A  | A
20 | B  | B
30 | C  | C

and

bar:
1 | A | X
2 | B | C
3 | A | A
4 | C | A
5 | B | B


I want to select all the rows in table bar where the second and third
column match an entry found in foo (that is to say, I want my result
to be 3 | A | A and 5 | B | B.

My attempt of:
select * from bar
where col2 in (select col2 from foo where bar.col2 = col2)
        and col3 in (select col3 from foo where bar.col3 = col3)

Does not work, and I understand that is should not (it returns 2 | B |
C, 3 | A | A, 4 | C | A, 5 | B | B).

Could someone give me a hand?

--
Rich
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to