Re: INSERT Syntax

From: "Josh Berkus" <josh(at)agliodbs(dot)com>
To: "Joseph Syjuco" <joseph(at)asti(dot)dost(dot)gov(dot)ph>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: INSERT Syntax
Date: 2001-09-03 19:33:42
Message-ID: web-112904@davinci.ethosmedia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Joseph,

> insert into table1(field1,field2) values (select field1, field2 from
> table
> 2);

Actually, that won't work in SQL Server either. The correct syntax (for
both databases) is:

INSERT INTO table1 ( field1, field2 )
SELECT field1, field2 FROM table2;

The "VALUES" syntax is only appropriate if you are inserting a set of
constants with no SELECT statement involved.

-Josh Berkus

______AGLIO DATABASE SOLUTIONS___________________________
Josh Berkus
Complete information technology josh(at)agliodbs(dot)com
and data management solutions (415) 565-7293
for law firms, small businesses fax 621-2533
and non-profit organizations. San Francisco

Attachment Content-Type Size
unknown_filename text/plain 2 bytes
unknown_filename text/plain 2 bytes
unknown_filename text/plain 2 bytes

In response to

  • at 2001-09-03 09:02:36 from Joseph Syjuco

Browse pgsql-sql by date

  From Date Subject
Next Message Josh Berkus 2001-09-03 19:39:26 Re: More on the TO DO wishlist
Previous Message Chris Ruprecht 2001-09-03 18:06:52 More on the TO DO wishlist