1
我有2个表有几列:删除不具有关联行中的另一个表中的行
parent (id, name, a)
child (id, parent_id, name)
我不能设法找到正确的SQL查询来删除那些没有孩子的父母和一个< 10这是针对Android 2.1附带的SQLite。任何人都可以帮忙?
我有2个表有几列:删除不具有关联行中的另一个表中的行
parent (id, name, a)
child (id, parent_id, name)
我不能设法找到正确的SQL查询来删除那些没有孩子的父母和一个< 10这是针对Android 2.1附带的SQLite。任何人都可以帮忙?
delete from parent
where a < 10
and not exists (select * from child where parent.id = child.parent_id)
做的另一种方式:
delete from parent
where a < 10
and id not in (select parent_id from child, parent b where child.parent_id = b.id)
非常感谢! :) – 2011-02-02 16:18:32