mysql 级联删除级联更新 update delete inner
正常update
update tb_platform_role set ROLE_NAME = '1' where ROLE_NAME = '1'
inner sql写法
sqlserver写法:
update tb_platform_role
set ROLE_NAME=''
from tb_platform_role a
inner join tb_platform_user b on a.ROLE_NAME = b.USER_NAME
where a.ROLE_NAME='xxx'
但是上面写法在mysql不对,mysql的用法:
update tb_platform_role AS a INNER JOIN tb_platform_user AS b
on a.ROLE_NAME = b.USER_NAME
SET a.ROLE_NAME='xxx'
WHERE a.ROLE_NAME='xxx'
删除的话差不多
正常
delete from tb_platform_role where ROLE_NAME='xxx'
sqlserver用法:
delete tb_platform_role
from tb_platform_role a
inner join tb_platform_user b on a.ROLE_NAME = b.USER_NAME
where a.ROLE_NAME='xxx'
sqlserver 可以用别名 delete a from tb_platform_role a 就行
mysql 用法 delete用法和sqlserver差不多 , 但是不能用表名 只能用后面表的别名 delete a from tb_platform_role a 可以
delete tb_platform_role from tb_platform_role a 不行
delete a from tb_platform_role AS a INNER JOIN tb_platform_user AS b
on a.ROLE_NAME = b.USER_NAME
WHERE a.ROLE_NAME='xxx'