X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 61EC352818 for ; Wed, 15 Jun 2005 09:22:10 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 82861-04 for ; Wed, 15 Jun 2005 12:22:00 +0000 (GMT) Received: from mail.interaction.ws (unknown [216.46.25.69]) by svr1.postgresql.org (Postfix) with ESMTP id EB2F452828 for ; Wed, 15 Jun 2005 09:21:58 -0300 (ADT) Received: from [192.168.0.93] (helo=BRUNO2500) by mail.interaction.ws with smtp (Exim 4.50) id 1DiWuA-0007uu-2D; Wed, 15 Jun 2005 08:22:02 -0400 Message-ID: <006b01c571a4$dbbb7d40$5d00a8c0@BRUNO2500> From: =?iso-8859-1?Q?Bruno_Pr=E9vost?= To: "Praveen Raja" Cc: References: <002401c5719e$dc9682b0$4c0ca8c0@sek.se> Subject: Re: update syntax Date: Wed, 15 Jun 2005 08:22:11 -0400 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0068_01C57183.53FE33F0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200506/168 X-Sequence-Number: 21769 This is a multi-part message in MIME format. ------=_NextPart_000_0068_01C57183.53FE33F0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Try something like this UPDATE table1 SET col1 =3D b.col1 FROM table1 b WHERE table1.col2 =3D b.col2 and table1.col3 =3D 'something' and b.col3 =3D 'somethingelse' ----- Original Message -----=20 From: Praveen Raja=20 To: pgsql-sql@postgresql.org=20 Sent: Wednesday, June 15, 2005 7:39 AM Subject: [SQL] update syntax Hi, While using Ms SQL server I used to write update statements like this, UPDATE a SET a.col1 =3D b.col1 FROM table1 a INNER JOIN table1 b ON a.col2 =3D b.col2 WHERE a.col3 =3D 'something' AND b.col3 =3D 'somethingelse' But I can't seem to do this in postgres, it gives me an error saying = 'syntax error at or near "."'. How can I do something similar to this = i.e. join on the same table? Thanks, /P ------=_NextPart_000_0068_01C57183.53FE33F0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Try something like this
 
UPDATE table1
SET col1 =3D = b.col1
FROM table1=20 b
WHERE table1.col2 =3D b.col2 and
table1.col3 =3D =91something=92 = and
b.col3 =3D=20 =91somethingelse=92
 
----- Original Message -----
From:=20 Praveen Raja
Sent: Wednesday, June 15, 2005 = 7:39=20 AM
Subject: [SQL] update = syntax

Hi,

 

While using Ms SQL = server I used=20 to write update statements like this,

 

UPDATE a SET a.col1 =3D=20 b.col1

FROM table1 = a

INNER JOIN table1=20 b

ON a.col2 =3D=20 b.col2

WHERE a.col3 =3D=20 =91something=92

AND b.col3 =3D=20 =91somethingelse=92

 

But I can=92t seem to do = this in=20 postgres, it gives me an error saying =91syntax error at or near = =93.=94=92. How can I=20 do something similar to this i.e. join on the same = table?

 

Thanks,

/P

------=_NextPart_000_0068_01C57183.53FE33F0--