SQlite删除内连接

时间:2015-01-15 20:10:13

标签: sqlite

我已经阅读了很多其他答案,但无法使其正常工作!

select * from invTypes
inner join invGroups on invtypes.groupID = invgroups.groupID
where invGroups.categoryID = 25;

如果类别ID匹配到25

,我只想删除invTypes中的记录

非常感谢帮助

我已经尝试过了:

delete from invTypes
inner join invGroups on invtypes.groupID = invgroups.groupID
where invGroups.categoryID = 25;

给出错误: “inner”附近:语法错误:

DELETE FROM invTypes
WHERE groupID in ( SELECT groupID FROM invGroups INNER JOIN invTypes ON (invGroups.groupID = invTypes.groupID) 
WHERE invGroups.categoryID = 25);

给出: 模糊列名:groupID:DELETE FROM invTypes WHERE groupID in(SELECT groupID FROM invGroups INNER JOIN invTypes ON(invGroups.categoryID = invTypes.categoryID)WHERE invGroups.categoryID = 25);

2 个答案:

答案 0 :(得分:2)

您可以将deletewhere子句

一起使用
delete from invTypes
where groupId in ( select groupId from invGroups where CategoryID =25)

答案 1 :(得分:-2)

DELETE invTypes
FROM invTypes
INNER JOIN invGroups
ON invTypes.groupID = invGroups.groupID
WHERE invGroups.categoryID = 25;