SQLite 删除内连接 [英] SQlite delete inner join

查看:19
本文介绍了SQLite 删除内连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了很多其他答案,但无法解决这个问题!

I have read alot of other answers but cannot get this working!.

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

如果类别 ID 与 25 匹配,我只想从 invTypes 中删除记录

I simply want to delete the record from invTypes if the category ID matches to 25

非常感谢您的帮助

我已经试过了:

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

给出错误:靠近内部":语法错误:

Gives error: near "inner": syntax error:

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 invTypesWHERE groupID in (SELECT groupID FROM invGroups INNER JOIN invTypes ON (invGroups.categoryID = invTypes.categoryID) WHERE invGroups.categoryID = 25);

Gives: ambiguous column name: groupID: DELETE FROM invTypes WHERE groupID in ( SELECT groupID FROM invGroups INNER JOIN invTypes ON (invGroups.categoryID = invTypes.categoryID) WHERE invGroups.categoryID = 25);

推荐答案

你可以使用 deletewhere 子句

you can use delete with a where clause

delete from invTypes
where groupId in ( select groupId from invGroups where CategoryID =25)

这篇关于SQLite 删除内连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆