Re: INSERT... WHERE

From: Chris Angelico <rosuav(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: INSERT... WHERE
Date: 2013-01-14 04:44:01
Message-ID: CAPTjJmqKotELvFfhFFRXGTatEE7KtU2R+neEzf8DKRXhxQ=1EQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Jan 14, 2013 at 3:37 PM, Robert James <srobertjames(at)gmail(dot)com> wrote:
> Thanks. But how do I do that where I have many literals? Something like:
>
> INSERT INTO seltest (id, a, b) SELECT (1,2,3),(4,5,6),(7,8,9) WHERE b
> IN (SELECT ...)

You can use WITH clauses in crazy ways with PostgreSQL. I haven't
actually tried it, but you should be able to put your VALUES behind a
WITH, then SELECT from that WHERE blah blah, and INSERT that SELECT.

As they say, knock yourself out! :)

ChrisA

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Darren Duncan 2013-01-14 06:26:23 Re: Bulk INSERT with individual failure
Previous Message Robert James 2013-01-14 04:37:08 Re: INSERT... WHERE