Search Postgresql Archives

Re: What is *wrong* with this query???

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

 



On 05/11/2011 04:51, Steve Murphy wrote:
> select schedule.id as sched_id, bld.id as bid
>     from
>         schedule
>         left join company on schedule.company = company.id
>         left join (select * from building where building.company =
> company.id order by id limit 1)  as bld
>     where
>         schedule.status = 'active' and company.status = 'active' and
> bld.status = 'active';

You're missing the "on" bit after the join, and I think an alias for the
inline view also:

...left join (....) x on (schedule.whatever = x.whatever)

BTW it's a good idea to use explicit column names, not "select *" -
makes for easier bug-finding.

Ray.

-- 
Raymond O'Donnell :: Galway :: Ireland
rod@xxxxxx

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[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