SELECT * FROM A WHERE projid in (SELECT projid FROM B WHERE ptask = 'a'); will probably fill the bill.
If I where to run your query, I would do a select A.* from A inner join B on A.a = b.ProjId where b.ptask='a' the join may optimize better than the in (select ...) On Thu, Jan 23, 2014 at 8:11 PM, jose isaias cabrera <cabr...@wrc.xerox.com>wrote: > > Greetings! > > I have these tables A and B: > A > id,projid,a,b > 1,1,'a','h' > 2,2,'b','i' > 3,3,'c','j' > 4,4,'d','k' > 5,5,'e','l' > ... > ... > > > B > id,projid,ptask > 101,1,'a' > 102,2,'b' > 103,3,'a' > 104,4,'b' > 105,5,'a' > ... > ... > > When I do this SELECT, > > SELECT * FROM A WHERE projid = (SELECT projid FROM B WHERE ptask = 'a'); > > This only returns one record (record 1) where it should return all the > records with ptask = 'a'. Will someone point me to the right syntax to get > this correct? Thanks for the help. > > josé > _______________________________________________ > 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