From: | Raymond O'Donnell <rod(at)iol(dot)ie> |
---|---|
To: | Steve Murphy <smurphy(at)intorrent(dot)com> |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: What is *wrong* with this query??? |
Date: | 2011-11-05 19:35:34 |
Message-ID: | 4EB59006.4070209@iol.ie |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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(at)iol(dot)ie
From | Date | Subject | |
---|---|---|---|
Next Message | Tair Sabirgaliev | 2011-11-05 19:38:52 | Re: Distinct on a non-sort column |
Previous Message | Oliver Kohll - Mailing Lists | 2011-11-05 19:24:03 | Fwd: explain analyse and nested loop joins |