SQL DELETE with JOIN another table for WHERE condition

后端 未结 4 1572
说谎
说谎 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:10

    How about:

    DELETE guide_category  
      WHERE id_guide_category IN ( 
    
            SELECT id_guide_category 
              FROM guide_category AS gc
         LEFT JOIN guide AS g 
                ON g.id_guide = gc.id_guide
             WHERE g.title IS NULL
    
      )
    

提交回复
热议问题