On Tue, Sep 8, 2009 at 12:58 AM, Dennis Volodomanov<denn...@conceiva.com> wrote: > Thank you for the quick replies and sorry for not being too clear. > > I will try to state the problem more clearly, without my own attempts to > solve it, as they are incorrect anyway. > > The simplified schemas again: > > CREATE TABLE TABLEA ( ID INTEGER PRIMARY KEY, IDB INTEGER, IDC INTEGER, IDD > INTEGER ); > CREATE TABLE TABLEB ( ID INTEGER PRIMARY KEY, DATA ); > CREATE TABLE TABLEC ( ID INTEGER PRIMARY KEY, DATA ); > CREATE TABLE TABLED ( ID INTEGER PRIMARY KEY, DATA ); > > And some sample data: > > TABLEA > 1|0|0|0 > 2|1|0|0 > 3|2|1|1 > 4|0|1|2 > 5|1|2|0 > 6|3|1|3 > > TABLEB, TABLEC, TABLED > 1|A > 2|B > 3|C > > The problem is that I need to grab rows from TABLEB where the ID of that row > appears in TABLEA, at the same time satisfying other conditions such as IDC > of that row also has multiple values (IDC=1 OR IDC=2, for example). > > So, given: > > IDC=1 AND (IDD=1 OR IDD=3) > > I need to get rows 2 and 3 from TABLEB.
SELECT * FROM TABLEB WHERE ID IN ( SELECT IDB FROM TABLEA WHERE IDC = 1 AND IDD IN (1, 3) ) > > Hopefully this makes more sense :) > > Best regards, > > Dennis > > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > -- Puneet Kishor http://www.punkish.org Carbon Model http://carbonmodel.org Charter Member, Open Source Geospatial Foundation http://www.osgeo.org Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor Nelson Institute, UW-Madison http://www.nelson.wisc.edu ----------------------------------------------------------------------- Assertions are politics; backing up assertions with evidence is science ======================================================================= Sent from Madison, WI, United States _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users