delete 语句中含有EXISTS

bigstrongzhang723 2011-08-08 04:18:16
DELETE from power_role_fun a
where a.role_id ='0001' and
EXISTS (select b.func_id from power_system_function b
where b.system_code = '03' and b.func_id = a.fun_id );


[SQL]

DELETE power_role_fun a
where a.role_id ='0001' and
EXISTS (select b.func_id from power_system_function b
where b.system_code = '03' and b.func_id = a.fun_id );
[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where a.role_id ='0001' and
EXISTS (select b.func_id from power_system_funct' at line 2
求正解!
...全文
803 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
gw6328 2011-08-10
  • 打赏
  • 举报
回复
顶3楼。
rucypli 2011-08-08
  • 打赏
  • 举报
回复
delete from power_role_fun 
where role_id ='0001'
and a.fun_id in(select func_id from power_system_function where system_code = '03')
WWWWA 2011-08-08
  • 打赏
  • 举报
回复
DELETE a FROM power_role_fun a
WHERE a.role_id ='0001' AND
EXISTS (SELECT b.func_id FROM power_system_function b
WHERE b.system_code = '03' AND b.func_id = a.fun_id );
or

DELETE a FROM power_role_fun a inner join power_system_function b on b.func_id = a.fun_id
where a.role_id ='0001' AND b.system_code = '03'
shine333 2011-08-08
  • 打赏
  • 举报
回复
delete的时候,貌似不能有别名
小姜哥 2011-08-08
  • 打赏
  • 举报
回复
我知道为什么,但是不会解决,把表别名去掉就没有问题了。

56,687

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧