SQL DELETE with JOIN another table for WHERE condition

后端 未结 4 1578
说谎
说谎 2020-11-27 17:44

I have to delete rows from guide_category that have no relation with guide table (dead relations).

Here is what I want to do, but it of cou

4条回答
  •  广开言路
    2020-11-27 18:22

    I think, from your description, the following would suffice:

    DELETE FROM guide_category 
    WHERE id_guide NOT IN (SELECT id_guide FROM guide)
    

    I assume, that there are no referential integrity constraints on the tables involved, are there?

提交回复
热议问题