update t set t.sal = t.sal* 1.1 from ( select prof , max(sal) as bsal from t group by prof) t1 where t.prof = t1.prof and t.sal < t1.bsal
展开全部
收起
热心网友回答时间:2025-01-31 00:53
是mysql 不允许在update句子中同时存在select,还有一个更简单的方法,全网我都没搜索到答案,自己琢磨的,你可以试试. 例子: 使用变量 set @ss = (select max(sal) from t y where x.prof = y.prof GROUP BY prof)) ; 然后 update t,(select tno from t x where sal<@ss 省略..................; 没有任何报错
展开全部
收起
热心网友回答时间:2025-01-31 00:51
update t set t.sal=t.sal*1.1 where t.tno in ( 在这个括号里查询出你要加10%的tno ); 注:修改表t的sal,让他在原来的基础上增加10%,条件限定是要修改的记录