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
求正解!

解决方案 »

  1.   

    delete的时候,貌似不能有别名
      

  2.   

    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 );
    orDELETE 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'
      

  3.   

    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')