Re: advice

Поиск
Список
Период
Сортировка
От Josh Berkus
Тема Re: advice
Дата
Msg-id 200310221327.25270.josh@agliodbs.com
обсуждение исходный текст
Ответ на advice  (Andrei Ivanov <andrei.ivanov@ines.ro>)
Ответы Re: advice  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-novice
Andrei,

> I'm planning to something like
> INSERT INTO first_table
>   SELECT * FROM second_table s WHERE
>      NOT EXISTS (SELECT 1 FROM first_table WHERE id = s.id)

This is the way to do it, athough I'd fully qualify both "id" fields in the
subquery and use an alias to avoid confusion, e.g.
NOT EXISTS (SELECT 1 FROM first_table f2 WHERE f2.id = s.id)

--
-Josh Berkus
 Aglio Database Solutions
 San Francisco


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

Предыдущее
От: Andrei Ivanov
Дата:
Сообщение: advice
Следующее
От: "w fm3"
Дата:
Сообщение: Update rule on multiple tables fails?