我已经阅读了很多其他答案,但无法使其正常工作!
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);
答案 0 :(得分:2)
您可以将delete
与where
子句
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;