关于SELECT....FOR UPDATE OF [fields]用法

如果SELECT语句中有使用Alias,DISTINCT operator, CURSORexpression, SET(union,union all,minus,intersect) operators,group_by_clause, or aggregate(count,max,mix,avg) functions,则无法到查询返回值进行更新;
 
eg:
 
TABLE:emp
 
id       name      salary
==========================
10       aaaa       1234
13       abcd       2313
15       cdue       1245
...       ...        ...
 
 
case 1> 使用别名;
 
select id emp_id, name emp_name ,salary  emp_salary
from emp
where id=10
for update;  --这样是无法达到更新的目的;
 
可修改成
 
select id emp_id, name emp_name ,salary 
from emp
where id=10
for update of salary --对salary字段进行更新;

         

            成长

       /      |     \

    学习   总结   分享

QQ交流群:122230156

原文地址:https://www.cnblogs.com/benio/p/2580222.html