Thanks Igor and Puneet, These are very different solutions, or so it appears to me.
Any idea whether the join or the sub-select would be faster? In my example there is an index on tagid. Wednesday, April 9, 2008, 8:12:53 AM, you wrote: IT> 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. IT> select t1.noteid IT> from tableName t1 join tableName t2 on (t1.noteid = t2.noteid) IT> where t1.tagid='a' and t2.tagid='b'; IT> Igor Tandetnik IT> _______________________________________________ IT> sqlite-users mailing list IT> sqlite-users@sqlite.org IT> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users -- 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