Re: advice

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Andrei Ivanov <andrei(dot)ivanov(at)ines(dot)ro>, pgsql-novice(at)postgresql(dot)org
Subject: Re: advice
Date: 2003-10-22 20:27:25
Message-ID: 200310221327.25270.josh@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

  • advice at 2003-10-22 19:58:12 from Andrei Ivanov

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Bruce Momjian 2003-10-22 20:37:02 Re: Expressional Indexes
Previous Message Josh Berkus 2003-10-22 20:22:26 Re: Expressional Indexes