UPDATE table SET col = (SELECT ...)

From: Eric Marsden <emarsden(at)mail(dot)dotcom(dot)fr>
To: pgsql-sql(at)postgresql(dot)org
Subject: UPDATE table SET col = (SELECT ...)
Date: 1998-12-30 17:01:28
Message-ID: wzi4sqdzhqv.fsf@mail.dotcom.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello,

If I understand the SQL references I have read, UPDATEs are allowed to
pull data from SELECT statements, something like

UPDATE table SET col1 = (SELECT val1 FROM table WHERE id = 34),
SET col2 = (SELECT val2 FROM table WHERE id = 34)
WHERE id = 35;

However, the PostgreSQL parser chokes on the 'SELECT'. The
documentation says

UPDATE table SET column = expression [, ...]
[ FROM fromlist ]
[ WHERE condition ]

expression = A valid expression or value to assign to column.

I don't know exactly how to interpret `valid expression'.

--
Eric Marsden
emarsden @ mail.dotcom.fr
It's elephants all the way down

Browse pgsql-sql by date

  From Date Subject
Next Message pierre 1998-12-31 16:27:34 html table output of table space
Previous Message Gregory Holston 1998-12-30 14:22:12 Re: [SQL] booleans