From: | Bruno Prévost <bp(at)interaction(dot)ws> |
---|---|
To: | "Praveen Raja" <praveen(dot)raja(at)netlight(dot)se> |
Cc: | <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: update syntax |
Date: | 2005-06-15 12:49:52 |
Message-ID: | 009001c571a8$b90eb380$5d00a8c0@BRUNO2500 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
I don't know if you can do that using the same logic.
Perhaps someone else can help?
For sure, you can use a subselect.
delete from table1
where col1 in (SELECT a.col1
FROM table1 a JOIN table1 b ON a.col2 = b.col2
WHERE a.col3 = 'something'
AND b.col3 = 'somethingelse')
----- Original Message -----
From: Praveen Raja
To: 'Bruno Prévost'
Cc: pgsql-sql(at)postgresql(dot)org
Sent: Wednesday, June 15, 2005 8:35 AM
Subject: RE: [SQL] update syntax
Thanks. The UPDATE works ok now. But using the same logic it doesn't seem possible to delete rows. Is this also possible?
/P
-----Original Message-----
From: Bruno Prévost [mailto:bp(at)interaction(dot)ws]
Sent: 15 June 2005 14:22
To: Praveen Raja
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] update syntax
Try something like this
UPDATE table1
SET col1 = b.col1
FROM table1 b
WHERE table1.col2 = b.col2 and
table1.col3 = 'something' and
b.col3 = 'somethingelse'
----- Original Message -----
From: Praveen Raja
To: pgsql-sql(at)postgresql(dot)org
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 = b.col1
FROM table1 a
INNER JOIN table1 b
ON a.col2 = b.col2
WHERE a.col3 = 'something'
AND b.col3 = '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
From | Date | Subject | |
---|---|---|---|
Next Message | Bruno Wolff III | 2005-06-15 14:31:24 | Re: Converting varchar to bool |
Previous Message | Praveen Raja | 2005-06-15 12:35:42 | Re: update syntax |