SQL-question (JOIN) - Mailing list pgsql-general

From pilsl@goldfisch.at
Subject SQL-question (JOIN)
Date
Msg-id 20030131212051.GI14689@goldfisch.at
Whole thread Raw
Responses Re: SQL-question (JOIN)
Re: SQL-question (JOIN)
Re: SQL-question (JOIN)
Re: SQL-question (JOIN)
List 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 by date:

Previous
From: Luis Magaña
Date:
Subject: For each record in SELECT
Next
From: Robert Treat
Date:
Subject: Re: using pgcrypt