如何将此SELECT步骤更改为DELETE语句以使用mysql

时间:2015-09-23 17:40:38

标签: mysql sql

尝试更改此SELECT语句

SELECT t1.user_id FROM jforum_users t1 WHERE EXISTS 
      (SELECT t3.user_id 
          FROM jforum_users t3 
             LEFT JOIN jforum_posts t2 ON t3.user_id=t2.user_id  
          WHERE user_website IS NOT NULL 
             AND t2.user_id IS  null 
             AND t1.user_id=t3.user_id
       );

进入DELETE语句

DELETE FROM jforum_users t1 WHERE EXISTS
   (SELECT t3.user_id 
       FROM jforum_users t3 
          LEFT JOIN jforum_posts t2 ON t3.user_id=t2.user_id  
       WHERE user_website IS NOT NULL
         AND t2.user_id IS NULL 
         AND t1.user_id=t3.user_id
   );

SELECT语句有效但DELETE但不喜欢它给出错误:

  

错误1064(42000):您的SQL语法有错误;检查   手册,对应右边的MySQL服务器版本   在'where exists附近使用的语法(从jforum_users中选择t3.user_id)   t3在第1行左边加入jforum_posts t2 o'

我做错了什么?

0 个答案:

没有答案