delete from gb_main a where a.gb_read = 0 and a.gb_reid not in (select b.gb_id  from gb_main b)
执行的话,提示:
Error Code : 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.gb_read = 0 and a.gb_reid not in (select b.gb_id  from gb_main b)' at line 1
(0 ms taken)
是不是delete 后面不能跳in?select * from gb_main a where a.gb_read = 0 and a.gb_reid not in (select b.gb_id  from gb_main b)  这一句是可以执行的这些数据全在一张表里面

解决方案 »

  1.   

    delete from gb_main  where gb_read = 0 and gb_reid not in (select gb_id  from gb_main);
      

  2.   

    可以含in 
    delete from gb_main a where (a.gb_read = 0) and (a.gb_reid not in (select b.gb_id  from gb_main b))
      

  3.   

    如果delete的时候使用别名的话,那么delete后边必须加上别名.如下:delete a from gb_main a where a.gb_read = 0 and a.gb_reid not in (select b.gb_id from gb_main b)
      

  4.   

    执行不了啊!不管是在mysql 的命令提示符环境下,还是在SQLyog Enterprise 里面,都执行不了!将前面的delete from 改成select * from 就可以执行!提示:
    Error Code : 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.gb_read  =  0)  and  (a.gb_reid  not  in  (select  b.gb_id    from  gb' at line 1
    (0 ms taken)