On 4/8/08, Neville Franks <[EMAIL PROTECTED]> wrote: > I have a table that holds 1 to many items. To keep it simple say it > has 2 columns: tagid and noteid. A given tagid can have many noteid's. > ex. > tagid noteid > ------ ------ > a 1 > a 4 > a 7 > b 7 > b 3 > c 1 > > I want to perform a query: give me all noteid's that have tagid a and > tagid b. The result for the example above would be: > > noteid > ------ > 7 >
select noteid from t where tagid = 'b' and noteid in (select noteid from t where tagid = 'a'); > Can someone point me in the right direction. I am also interested in > optimal performance here. > > I'm new to SQL and so far I am just doing simple select's. Thanks. > > -- > Best regards, > Neville Franks, http://www.surfulater.com http://blog.surfulater.com > > > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > -- Puneet Kishor http://punkish.eidesis.org/ Nelson Institute for Environmental Studies http://www.nelson.wisc.edu/ Open Source Geospatial Foundation (OSGeo) http://www.osgeo.org/ _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users