On Fri, Nov 4, 2011 at 10:51 PM, Steve Murphy <smurphy@xxxxxxxxxxxxx> 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'; Looks like you need an on clause after the second left join. -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general