mysql和oracle中进行工资查询后修改或删除
报错:
You can’t specify target table ‘userroles’ for update in FROM clause
解决方法
oracle:
update storage set sstotal=salary*0.5
where salary in ( select sstotal from storage);
mysql:
个人认为oracle和mysql的本质区别就在于mysql需要再进行一次查询,而oracle不需要二次查询,就可以获取到你想要删除或者修改的东西。
本身的表不让你进行改动,那就把查出来的东西进行改造,变成一个新的表进行改变。
update storage set sstotal=sstotal+500
where sstotal in
( select a.sstotal FROM
(
SELECT sstotal from storage
) a)
mysql删除
delete from wy_product_v1 where productId not in(
select w.productId from(
select wy_product_v1.productId from wy_product_v1,wy_product_item where wy_product_v1.productId=wy_product_item.productId
) w
);