Why can't I use SELECT … FOR UPDATE with aggregate functions?

后端 未结 3 946
臣服心动
臣服心动 2021-01-01 22:23

I have an application where I find a sum() of a database column for a set of records and later use that sum in a separate query, similar to the following (made up tables, bu

3条回答
  •  天命终不由人
    2021-01-01 23:09

    The syntax select . . . for update locks records in a table to prepare for an update. When you do an aggregation, the result set no longer refers to the original rows.

    In other words, there are no records in the database to update. There is just a temporary result set.

提交回复
热议问题