I have 2 tables with identical schemas.
What I have to do is insert in the 1st table all the rows from the
2nd table that don't exist in the 1st.
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)
but I'm not sure this is the best way to do it...
Would anyone care to suggest a better query to do this ?
- Re: advice at 2003-10-22 20:27:25 from Josh Berkus
- Re: advice at 2003-10-25 20:31:52 from Paul Ganainm
pgsql-novice by date
|Next:||From: Josh Berkus||Date: 2003-10-22 20:22:26|
|Subject: Re: Expressional Indexes|
|Previous:||From: Tom Lane||Date: 2003-10-22 19:44:58|
|Subject: Re: Expressional Indexes |