From: | pilsl(at)goldfisch(dot)at |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | SQL-question (JOIN) |
Date: | 2003-01-31 21:20:52 |
Message-ID: | 20030131212051.GI14689@goldfisch.at |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)goldfisch(dot)at
http://www.goldfisch.at
From | Date | Subject | |
---|---|---|---|
Next Message | Luis Magaña | 2003-01-31 21:21:17 | For each record in SELECT |
Previous Message | Dmitry Tkach | 2003-01-31 21:08:47 | Re: Query performance PLEASE HELP |