Re: INSERT... WHERE - Mailing list pgsql-general

From Ian Lawrence Barwick
Subject Re: INSERT... WHERE
Date
Msg-id CAB8KJ=he+ZfrRpDEpmxs6Fi5M-t0qYgpJJrAA6vMPu+pvCwVcg@mail.gmail.com
Whole thread Raw
In response to INSERT... WHERE  (Robert James <srobertjames@gmail.com>)
Responses Re: INSERT... WHERE  (Robert James <srobertjames@gmail.com>)
List pgsql-general
2013/1/14 Robert James <srobertjames@gmail.com>:
> I have a lot of VALUES I want to INSERT.  But only a subset of them -
> only those that meet a JOIN criteria involving another table.
>
> I could INSERT them into a temp table, and then do a SELECT INTO.  But
> do I need to do that?  Is there any way to do a INSERT... VALUES ...
> WHERE...

INSERT INTO ... SELECT is what you are looking for.

Simple example:

  CREATE TABLE seltest (id INT);
  INSERT INTO seltest (id) SELECT 1;


HTH

Ian Lawrence Barwick


pgsql-general by date:

Previous
From: Scott Marlowe
Date:
Subject: Re: INSERT... WHERE
Next
From: Edson Richter
Date:
Subject: Re: Linux Distribution Preferences?