Re: Help with UNION query

Поиск
Список
Период
Сортировка
От Andreas Joseph Krogh
Тема Re: Help with UNION query
Дата
Msg-id 200509042008.21080.andreak@officenet.no
обсуждение исходный текст
Ответ на Help with UNION query  (Andreas Joseph Krogh <andreak@officenet.no>)
Ответы Re: Help with UNION query  (Andreas Joseph Krogh <andreak@officenet.no>)
Список pgsql-sql
Replying to my self...

Here's a somewhat simpler version without the IN-queries:

SELECT g.id
from onp_group g, onp_user_group ug
where g.groupname = ug.groupname AND ug.username = 'andreak'
UNION
SELECT gc.child_id
FROM onp_group_children gc, onp_group g, onp_user_group ug
WHERE gc.group_id = g.id AND g.groupname = ug.groupname
AND ug.username = 'andreak';

But I would very much appreciate if someone manages to rewrite this query so
that it doesn't specify ug.username='anderak' twice.

--
Andreas Joseph Krogh <andreak@officenet.no>
Senior Software Developer / Manager
gpg public_key: http://dev.officenet.no/~andreak/public_key.asc
------------------------+---------------------------------------------+
OfficeNet AS            | The most difficult thing in the world is to |
Hoffsveien 17           | know how to do a thing and to watch         |
PO. Box 425 Skøyen      | somebody else doing it wrong, without       |
0213 Oslo               | comment.                                    |
NORWAY                  |                                             |
Phone : +47 22 13 01 00 |                                             |
Direct: +47 22 13 10 03 |                                             |
Mobile: +47 909  56 963 |                                             |
------------------------+---------------------------------------------+

В списке pgsql-sql по дате отправления:

Предыдущее
От: Andreas Joseph Krogh
Дата:
Сообщение: Help with UNION query
Следующее
От: Andreas Joseph Krogh
Дата:
Сообщение: Re: Help with UNION query