Re: advice - Mailing list pgsql-novice

From Josh Berkus
Subject Re: advice
Date
Msg-id 200310221327.25270.josh@agliodbs.com
Whole thread Raw
In response to advice  (Andrei Ivanov <andrei.ivanov@ines.ro>)
Responses Re: advice
List 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 by date:

Previous
From: Andrei Ivanov
Date:
Subject: advice
Next
From: "w fm3"
Date:
Subject: Update rule on multiple tables fails?