On Fri, Jan 31, 2003 at 22:20:52 +0100,
pilsl@goldfisch.at wrote:
> 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.
I think you want something like this:
select coalesce(table2.name,table1.name) from table1 right join table2
using (uid);
(Warning the above wasn't actually tested for syntax errors. It also assumes
that name is not null in table2.)