Search Postgresql Archives

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

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

 



Mark Harrison <mh@xxxxxxxxx> 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
>             version=(select headver from p4_files where p4path like '%/date.txt');

Use a row-wise comparison, viz

select id from p4_versions
where (versionof, version) = (select id, headver from p4_files
			      where p4path like '%/date.txt');

			regards, tom lane


[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