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
r...@iol.ie

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

Reply via email to