| От | Bruno Wolff III |
|---|---|
| Тема | Re: SQL-question (JOIN) |
| Дата | |
| Msg-id | 20030201010745.GB14084@wolff.to обсуждение исходный текст |
| Ответ на | SQL-question (JOIN) (pilsl@goldfisch.at) |
| Список | pgsql-general |
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.)
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера