Re: Self-Referencing
От | Christof Glaser |
---|---|
Тема | Re: Self-Referencing |
Дата | |
Msg-id | 01032911273700.00783@pinguin обсуждение исходный текст |
Ответ на | Self-Referencing (David Olbersen <dave@slickness.org>) |
Список | 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
В списке pgsql-sql по дате отправления: