Re: [GENERAL] query that needs two nested queries, is this the best

2006-04-28 Thread Mark Harrison
Richard Huxton wrote: SELECT id FROM p4_versions WHERE (versionof, version) IN (SELECT id,headver FROM p4_files WHERE ...) Ahh, just what I was looking for... Thanks All! Mark ---(end of broadcast)--- TIP 4: Have you searched our list archives

Re: [GENERAL] query that needs two nested queries, is this the best way?

2006-04-27 Thread Jim Buttafuoco
why not a join like below (not tested) select id from p4_versions a join p4_files b on (a.versionof = b.id and a.version = b.headver) where p4path like '%/date.txt' -- Original Message --- From: Mark Harrison <[EMAIL PROTECTED]> To: Postgresql-General Sent: Thu, 27 Apr 2006 09

Re: [GENERAL] query that needs two nested queries, is this the best way?

2006-04-27 Thread Tom Lane
Mark Harrison <[EMAIL PROTECTED]> writes: > I've got a query that depends upon two pieces of data from another table for > use in a where clause. > scratch1=# select id from p4_versions where > versionof=(select id from p4_files where p4path like '%/date.txt') > and >

Re: [GENERAL] query that needs two nested queries, is this the best

2006-04-27 Thread Richard Huxton
Mark Harrison wrote: ### QUERY 3: combine the two statements above by using two subselects scratch1=# select id from p4_versions where versionof=(select id from p4_files where p4path like '%/date.txt') and version=(select headver from p4_files where p4path li