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 161DF5282B for ; Wed, 15 Jun 2005 09:35:45 -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 85170-06 for ; Wed, 15 Jun 2005 12:35:35 +0000 (GMT) Received: from mail.sto.netlight.se (1-1-10-39a.sh.sth.bostream.se [82.182.50.216]) by svr1.postgresql.org (Postfix) with ESMTP id BC12C52818 for ; Wed, 15 Jun 2005 09:35:32 -0300 (ADT) Received: from prraxp ([192.168.12.76]) by mail.sto.netlight.se (8.11.2/8.11.2) with ESMTP id j5FDOR318792; Wed, 15 Jun 2005 15:24:30 +0200 From: "Praveen Raja" To: "=?iso-8859-1?Q?'Bruno_Pr=E9vost'?=" Cc: Subject: Re: update syntax Date: Wed, 15 Jun 2005 14:35:42 +0200 Message-ID: <003001c571a6$c337a1c0$4c0ca8c0@sek.se> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0031_01C571B7.86C071C0" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.4024 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 In-Reply-To: <006b01c571a4$dbbb7d40$5d00a8c0@BRUNO2500> Importance: Normal X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.058 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200506/169 X-Sequence-Number: 21770 This is a multi-part message in MIME format. ------=_NextPart_000_0031_01C571B7.86C071C0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Thanks. The UPDATE works ok now. But using the same logic it doesn=92t seem possible to delete rows. Is this also possible? =20 /P =20 -----Original Message----- From: Bruno Pr=E9vost [mailto:bp@interaction.ws]=20 Sent: 15 June 2005 14:22 To: Praveen Raja Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] update syntax =20 Try something like this =20 UPDATE table1 SET col1 =3D b.col1 FROM table1 b WHERE table1.col2 =3D b.col2 and table1.col3 =3D =91something=92 and b.col3 =3D =91somethingelse=92 =20 ----- 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 =20 Hi, =20 While using Ms SQL server I used to write update statements like this, =20 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 =91something=92 AND b.col3 =3D =91somethingelse=92 =20 But I can=92t seem to do this in postgres, it gives me an error saying =91syntax error at or near =93.=94=92. How can I do something similar to = this i.e. join on the same table? =20 Thanks, /P ------=_NextPart_000_0031_01C571B7.86C071C0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable

Thanks. The = UPDATE works ok now. But using the same logic it doesn’t seem possible to = delete rows. Is this also possible?

 

/P<= /p>

 

-----Original Message-----
From: Bruno Pr=E9vost [mailto:bp@interaction.ws]
Sent: 15 June 2005 = 14:22
To: Praveen Raja
Cc: = pgsql-sql@postgresql.org
Subject: Re: [SQL] update = syntax

 

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 -----

From: Praveen Raja

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_0031_01C571B7.86C071C0--