SQL Server 通过左连接和分组进行更新
我正在更新我们的数据库,并且想要更新另一个表中没有现有项目的行。我可以将表连接在一起,但无法对表进行分组以获取行数
UPDATE dpt
SET dpt.active = 0
FROM DEPARTMENT dpt
LEFT JOIN DOCUMENTS doc on dpt.ID = doc.DepartmentID
GROUP BY dpt.ID
HAVING COUNT(doc.ID) = 0
我应该做什么?
I'm making an update to our database and would like to update rows that do not have existing items in another table. I can join the tables together, but am having trouble grouping the table to get a count of the number of rows
UPDATE dpt
SET dpt.active = 0
FROM DEPARTMENT dpt
LEFT JOIN DOCUMENTS doc on dpt.ID = doc.DepartmentID
GROUP BY dpt.ID
HAVING COUNT(doc.ID) = 0
What should I be doing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用:
Use: