数据表2:dede_archives 字段名 id
数据库表1和表2 是关联的 其中表1的aid 和表2的 id 是相同的id号 我想通过判断表1的字段:body 是否为空 ,为空就删除表2的对应的id
不知道应该如何去写
mysql数据库
3 个解决方案
#1
delete b from dede_addonarticle a ,dede_archives b where a.aid=b.id and a.body is null
#2
b 和 a 是什么东西 大神
#3
应该这样吧
delete from dede_archinves where exists (select * from dede_addonarticle where
aid = id and body is null )
delete from dede_archinves where exists (select * from dede_addonarticle where
aid = id and body is null )
#1
delete b from dede_addonarticle a ,dede_archives b where a.aid=b.id and a.body is null
#2
b 和 a 是什么东西 大神
#3
应该这样吧
delete from dede_archinves where exists (select * from dede_addonarticle where
aid = id and body is null )
delete from dede_archinves where exists (select * from dede_addonarticle where
aid = id and body is null )