delete from building where id in (SELECT b.id as bid from wharf as w right join building as b on w.id=b.wharf_id where w.user_id = -1)怎么改。

解决方案 »

  1.   

    delete a.* from building a left join wharf as w
    on w.id=a.wharf_id
    where w.user_id = -1
      

  2.   

    标准SQL
    delete from building
    where exists (select id from wharf where id=building.wharf_id and user_id = -1);MySQL 中还可以
    DELETE building FROM building, wharf WHERE building.wharf_id=wharf.id AND wharf.user_id=-1;