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

From Scott Marlowe
Subject Re: INSERT... WHERE
Date
Msg-id CAOR=d=1cC7MYRTmB5T=tPvmNoxZhkPu_DOJJ9qBNSXLk4xh7uQ@mail.gmail.com
Whole thread Raw
In response to INSERT... WHERE  (Robert James <srobertjames@gmail.com>)
List pgsql-general
On Sun, Jan 13, 2013 at 7:00 PM, Robert James <srobertjames@gmail.com> wrote:
> 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...

What you're probably looking for is an insert .. select statment like so:

insert into tablea (col1, col2, col3) select colx, coly, colz from
tableb where somecondition;


pgsql-general by date:

Previous
From: Lonni J Friedman
Date:
Subject: special procedure required when running pg_basebackup from a standby?
Next
From: Ian Lawrence Barwick
Date:
Subject: Re: INSERT... WHERE