从sql server 2000中的select中删除?
我想删除此选择查询返回的任何内容:
SELECT u.*
FROM (
SELECT userName, groupId, MAX(userId) AS maxId
FROM userTable
where userName <> '' and userName is not null
GROUP BY
userName, groupId
HAVING COUNT(*) > 1
) q
JOIN userTable u
ON u.userName = q.userName
AND u.groupId= q.groupId
AND u.userId <> q.maxId)
我该如何执行此操作?
I want to delete anything that is returned by this select query:
SELECT u.*
FROM (
SELECT userName, groupId, MAX(userId) AS maxId
FROM userTable
where userName <> '' and userName is not null
GROUP BY
userName, groupId
HAVING COUNT(*) > 1
) q
JOIN userTable u
ON u.userName = q.userName
AND u.groupId= q.groupId
AND u.userId <> q.maxId)
How can I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
像这样构造你的删除:
或者,如果你手上已经有一个漂亮的查询,你可以这样做:
Structure your delete like this:
Or, if you already have a spiffy query in hand, you can do this:
只需将 SELECT u.* 替换为 DELETE U 即可
just replace
SELECT u.*
withDELETE U