Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Ukxc0-0006wU-FA for pgsql-sql@arkaria.postgresql.org; Fri, 07 Jun 2013 14:25:52 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Ukxbz-0005UF-Uw for pgsql-sql@arkaria.postgresql.org; Fri, 07 Jun 2013 14:25:52 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Ukxbx-0005U7-Sv for pgsql-sql@postgresql.org; Fri, 07 Jun 2013 14:25:50 +0000 Received: from plane.gmane.org ([80.91.229.3]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Ukxbq-0006Ny-Ig for pgsql-sql@postgresql.org; Fri, 07 Jun 2013 14:25:49 +0000 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Ukxbo-0007nH-1j for pgsql-sql@postgresql.org; Fri, 07 Jun 2013 16:25:40 +0200 Received: from 217.110.94.121 ([217.110.94.121]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 07 Jun 2013 16:25:40 +0200 Received: from spam_eater by 217.110.94.121 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 07 Jun 2013 16:25:40 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-sql@postgresql.org From: Thomas Kellerer Subject: Re: Advice with an insert query Date: Fri, 07 Jun 2013 16:26:49 +0200 Lines: 17 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 217.110.94.121 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666 In-Reply-To: X-Pg-Spam-Score: 3.0 (+++) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org JORGE MALDONADO, 07.06.2013 15:58: > I need to insert records into a table where one value is fixed and 2 values come from a SELECT query, something like the following example: > > INSERT INTO table1 fld1, fld2, fl3 > VALUES value1, (SELECT fldx, fldy FROM table2) > > Is this valid? > > Respectfully, > Jorge Maldonado INSERT INTO table1 (fld1, fld2, fl3) SELECT value1, fldx, fldy FROM table2 -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql