环境:mysql4.1.6求以下语句的正确写法delete from a where id not in (select id from b)

解决方案 »

  1.   


    试试
    delete a from a,b where a.id != b.id;
      

  2.   

    delete from a where id not in (select id from b) ;这个语句,mySQL4已经支持了。你的报错信息是什么?
        [align=center]====  ====
    [/align]
      

  3.   

    delete a from a,b where a.id != b.id;
    上面这条语句可能会把你的表清空.最好先备份下.试试
    delete from a using a left join b on b.id=a.id where b.id is NULL
      

  4.   

    另外一种思路:
    delete from a where id not in (select id from b) 
    select a.* into newtt from a left join b on a.id=b.id where b.id is null