Re: What is *wrong* with this query??? - Mailing list pgsql-general

From Raymond O'Donnell
Subject Re: What is *wrong* with this query???
Date
Msg-id 4EB59006.4070209@iol.ie
Whole thread Raw
In response to What is *wrong* with this query???  (Steve Murphy <smurphy@intorrent.com>)
List 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@iol.ie

pgsql-general by date:

Previous
From: Tair Sabirgaliev
Date:
Subject: Re: What is *wrong* with this query???
Next
From: Tair Sabirgaliev
Date:
Subject: Re: Distinct on a non-sort column