Re: [sqlite] SELECTing from another SELECT

2014-01-25 Thread jose isaias cabrera
Igor Tandetnik wrote... On 1/23/2014 2:26 PM, St. B. wrote: 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' Careful - this

Re: [sqlite] SELECTing from another SELECT

2014-01-25 Thread jose isaias cabrera
"Igor Tandetnik" wrote on Friday, January 24, 2014 9:48 AM... On 1/24/2014 9:28 AM, jose isaias cabrera wrote: Igor Tandetnik wrote... On 1/23/2014 2:26 PM, St. B. wrote: SELECT * FROM A WHERE projid in (SELECT projid FROM B WHERE ptask = 'a'); will probably fill the bill. If I where to

Re: [sqlite] SELECTing from another SELECT

2014-01-25 Thread jose isaias cabrera
St. B. wrote... 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 ...)

Re: [sqlite] SELECTing from another SELECT

2014-01-24 Thread jose isaias cabrera
"Igor Tandetnik" wrote on Friday, January 24, 2014 9:48 AM... On 1/24/2014 9:28 AM, jose isaias cabrera wrote: Igor Tandetnik wrote... On 1/23/2014 2:26 PM, St. B. wrote: SELECT * FROM A WHERE projid in (SELECT projid FROM B WHERE ptask = 'a'); will probably fill the bill. If I where to

Re: [sqlite] SELECTing from another SELECT

2014-01-24 Thread Igor Tandetnik
On 1/24/2014 9:28 AM, jose isaias cabrera wrote: Igor Tandetnik wrote... On 1/23/2014 2:26 PM, St. B. wrote: 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

Re: [sqlite] SELECTing from another SELECT

2014-01-24 Thread jose isaias cabrera
Igor Tandetnik wrote... On 1/23/2014 2:26 PM, St. B. wrote: 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' Careful - this

Re: [sqlite] SELECTing from another SELECT

2014-01-24 Thread Hick Gunter
Use IN Projid = (SELECT ...) takes only the first value returned from the subselect -Ursprüngliche Nachricht- Von: jose isaias cabrera [mailto:cabr...@wrc.xerox.com] Gesendet: Donnerstag, 23. Jänner 2014 20:11 An: General Discussion of SQLite Database Betreff: [sqlite] SELECTing from

Re: [sqlite] SELECTing from another SELECT

2014-01-23 Thread James K. Lowden
On Thu, 23 Jan 2014 13:28:50 -0600 John McKown wrote: > > 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'. > > No, it is

Re: [sqlite] SELECTing from another SELECT

2014-01-23 Thread Igor Tandetnik
On 1/23/2014 2:26 PM, St. B. wrote: 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' Careful - this will produce a different

Re: [sqlite] SELECTing from another SELECT

2014-01-23 Thread jose isaias cabrera
St. B. wrote... 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 ...) Thanks.

Re: [sqlite] SELECTing from another SELECT

2014-01-23 Thread jose isaias cabrera
John McKown wrote... On Thu, Jan 23, 2014 at 1:11 PM, jose isaias cabrera 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'

Re: [sqlite] SELECTing from another SELECT

2014-01-23 Thread John McKown
On Thu, Jan 23, 2014 at 1:11 PM, jose isaias cabrera 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' >

Re: [sqlite] SELECTing from another SELECT

2014-01-23 Thread Igor Tandetnik
On 1/23/2014 2:11 PM, jose isaias cabrera wrote: SELECT * FROM A WHERE projid = (SELECT projid FROM B WHERE ptask = 'a'); You want WHERE projid IN (SELECT ...) IN operator accepts a set on the right; = operator only accepts a scalar (which comes from the first row of the sub-select). --

Re: [sqlite] SELECTing from another SELECT

2014-01-23 Thread jose isaias cabrera
Igor Tandetnik wrote... On 1/23/2014 2:11 PM, jose isaias cabrera wrote: SELECT * FROM A WHERE projid = (SELECT projid FROM B WHERE ptask = 'a'); You want WHERE projid IN (SELECT ...) IN operator accepts a set on the right; = operator only accepts a scalar (which comes from the first row

Re: [sqlite] SELECTing from another SELECT

2014-01-23 Thread St. B.
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

[sqlite] SELECTing from another SELECT

2014-01-23 Thread jose isaias cabrera
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 =