From: | Christof Glaser <gcg(at)gl(dot)aser(dot)de> |
---|---|
To: | David Olbersen <dave(at)slickness(dot)org>, <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Self-Referencing |
Date: | 2001-03-29 09:27:37 |
Message-ID: | 01032911273700.00783@pinguin |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Thursday, 29. March 2001 01:38, David Olbersen wrote:
[snip]
> SELECT
> building_id,
> num_buildings,
> (
> SELECT count( building_id )
> FROM building_portals
> WHERE building_id = THIS.building_id
> )
> FROM buildings;
Try this query (untested), using table aliases:
SELECT
b.building_id, b.num_buildings,
( SELECT count( bp.building_id )
FROM building_portals bp
WHERE bp.building_id = b.building_id )
FROM buildings b;
You could also write <table>.<field> instead.
Hope that helps.
Christof
--
gl.aser . software engineering . internet service
http://gl.aser.de/ . Planckstraße 7 . D-39104 Magdeburg
Tel. +49.391.7 44 77 10 . Fax +49.391.7 44 77 13 . Mobil 0177.77 92 84 3
From | Date | Subject | |
---|---|---|---|
Next Message | Cedar Cox | 2001-03-29 11:38:24 | Re: Function with now() | time 'now' | etc... |
Previous Message | Peter Mount | 2001-03-29 09:10:44 | Re: Calling Java from psql (was Re: requesting help) |