Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 like '%/date.txt');

This won't work if your LIKE matches more than one row anyway.

Try something like:

SELECT id FROM p4_versions WHERE
  (versionof, version) IN (SELECT id,headver FROM p4_files WHERE ...)

--
  Richard Huxton
  Archonet Ltd


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux