Maybe

select distinct bar.* from foo, bar
where foo.col2 = bar.col2 and foo.col3 = bar.col3

It's not clear from your requirements written below whether you need
'distinct' here or not but I've added it just in case...


Pavel

On Thu, Dec 3, 2009 at 4:34 PM, Rich Rattanni <ratta...@gmail.com> wrote:
> 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
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to