mentby.com
Blog | Jobs | Help | Signup | Login

UPDATE query based on a SELECT command.



Let's suppose that I have an UPDATE query which includes a SELECT as part
of it as follows:

UPDATE table1
SET field1 = (SELECT fieldx FROM table2 WHERE .........)

What happens if the result of the SELECT command does not return any row?

Respectfully,
Jorge Maldonado


JORGE MALDONADO Sat, 28 Jan 2012 10:54:54 -0800

A scalar subquery that returns no rows has a result of NULL.  This is
not specific to whether it's used in UPDATE.  See http://www.postgresql.org/docs/9.1/static/sql-expressions.ht[..]

            regards, tom lane

--
Sent via pgsql-novice mailing list (pgsql-novice*******)
To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-novice


Tom Lane Sat, 28 Jan 2012 11:13:10 -0800



Related Topics

Post a Comment