SQL Delete Rows Based on Another Table

前端 未结 6 1403
别那么骄傲
别那么骄傲 2020-12-13 18:44

This is probably very easy, but it\'s Monday morning. I have two tables:

Table1:

Field        | Type             | Null | Key | Default | Extra
id           


        
6条回答
  •  醉话见心
    2020-12-13 18:58

    Off the top of my head:

    delete from Table1 where id in (select id from table1 inner join table2 on Table1.group = Table2.group)
    

    I did this a little differently than other posters -- I think if there is a large number of rows on Table2 this might be better. Can someone please set me straight on that?

提交回复
热议问题