SQL-question (JOIN)

Поиск
Список
Период
Сортировка
От pilsl@goldfisch.at
Тема SQL-question (JOIN)
Дата
Msg-id 20030131212051.GI14689@goldfisch.at
обсуждение исходный текст
Ответы Re: SQL-question (JOIN)  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
Re: SQL-question (JOIN)  (Bruno Wolff III <bruno@wolff.to>)
Re: SQL-question (JOIN)  (Peter Eisentraut <peter_e@gmx.net>)
Re: SQL-question (JOIN)  (Keary Suska <hierophant@pcisys.net>)
Список pgsql-general
not sure if such question are on-topic here. (where would this
question be on-topic ?)

I need to join two tables with a logical "if-statement". If for a
certain row in table1 there is a related row in table2, then take the
row from table2 else take it from table1. The relation is a simple
equal on one column.

example:

table1:
uid | name
----+-----
1   | bob
2   | jim
3   | tom

table2:
uid | name
----+-----
2   | frank


the final join should return:
uid | name
----+-----
1   | bob
2   | frank
3   | tom

I played around with joins and intersects and distincts but only ended
up in complex unperformant queries that didnt do what I intended. I
miss the basic idea how to solve this.

thnx,
peter


--
mag. peter pilsl
IT-Consulting
tel: +43-699-1-3574035
fax: +43-699-4-3574035
pilsl@goldfisch.at
http://www.goldfisch.at

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

Предыдущее
От: Luis Magaña
Дата:
Сообщение: For each record in SELECT
Следующее
От: Robert Treat
Дата:
Сообщение: Re: using pgcrypt