SQL Server删除涉及两个表的查询
所以我在 SQL Server 中有表 A 和 B,分别有列 a 和 b。我想在伪查询命令中执行以下操作,但我似乎无法弄清楚。
我想
DELETE FROM A
WHERE a < 100 "and only if these selected (for deletion) values don't exist in column b in table B"
原因是我试图从表 A 中删除一些数据,但它给我一个错误,说 Aa 和 Bb 中的值之间存在约束。
这涉及别名吗?很混乱..
So I have tables A and B in SQL Server, and columns a and b respectively. I want to do the following in pseudo-query command, but I can't seem to figure it out.
I want to
DELETE FROM A
WHERE a < 100 "and only if these selected (for deletion) values don't exist in column b in table B"
The reason is that I'm trying to delete some data from table A, but it is giving me an error saying that there is a constraint between values in A.a and B.b .
Does this involve aliases? It is confusing..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用的是 SQL Server 2005 或更高版本,请尝试此操作:
对于 SQL Server 2000,这应该有效:
Try this if you are using SQL Server 2005 or newer:
For SQL Server 2000 this should work: