The queries of this question are here: http://sqlfiddle.com/#!17/16abc/5
I have this table person
which has two columns, id and age. When I run an update statement
update person
set age = ((select person.age) + 1)
where person.id = 1;
The age is set using the subquery((select person.age) + 1
.
What are the constraints which are applied on this select expression? Does it inherit the where clause of the update statement, retrieving the age of the row with person.id = 1?
From testing against some data it does appear that this is the case.
In this specific case the age can be set directly without resorting to a sub-select, but I was looking at this answer https://stackoverflow.com/a/6535089/1089912 and wondered if these select expressions when used in an update statement, inherit the constraints of the surrounding update statement.