sql 两个关联表数据删除的问题
问题描述:
例 表 a 有aid和name 表b 有bid bid数据为aid值 怎么根据name删除b表数据
答
delete t from b t where exists(select 1 from a where aid=t.bid and name ='你的name ')
答
delete from b where bid=(select aid from a where name='你的name')
答
delete from b where b.bid in (select aid from a where a.name = 'name');