Re: [GENERAL] Confusion in Insert Query syntax - Mailing list pgsql-general

From Bruce Momjian
Subject Re: [GENERAL] Confusion in Insert Query syntax
Date
Msg-id 199910060452.AAA20045@candle.pha.pa.us
Whole thread Raw
In response to Confusion in Insert Query syntax  (Shadkam Islam <shadkam@wipinfo.soft.net>)
List pgsql-general
> Hi All,
>
> If I type \h insert at psql it shows me,
>
>         INSERT INTO class_name [(attr1, ...attrN)]
>         VALUES (expr1,..exprN) |
>         SELECT [DISTINCT [ON attrN]]
>         expr1, ...exprN
>         [FROM from_clause]
>         [WHERE qual]
>         [GROUP BY group_list]
>         [HAVING having_clause]
>         [ { UNION [ALL] | INTERSECT | EXCEPT } SELECT ...];
>
>
> But when I tried the following query it gave the parse error
>
>
>     INSERT INTO EffortTable (EffortID)
>     VALUES (ValueForEffortID) |
>     SELECT MAX(EffortID) AS ValueForEffortID
>     FROM   EffortTable
>     WHERE  ProjectID=200;
>

The | means 'or' meaning INSERT INTO table VALUES    or  INSERT INTO
table SELECT.

--
  Bruce Momjian                        |  http://www.op.net/~candle
  maillist@candle.pha.pa.us            |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

pgsql-general by date:

Previous
From: Shadkam Islam
Date:
Subject: Confusion in Insert Query syntax
Next
From: Nikos Mouat
Date:
Subject: You are really hosed.