SQL Server:两个游标迭代

发布于 2024-12-27 19:08:07 字数 137 浏览 2 评论 0原文

在 SQL Server 中,我必须使用两个游标来迭代两个表。但我对此有一个问题,因为使用两个游标进行选择的结果包含重复的行。所以我的问题是如何从 SQL Server 中的两个或多个游标进行迭代,因为您必须知道这两个游标相互依赖。

提前致谢。

In SQL Server, I have to use two cursor to iterate from two tables. But I have a problem with this because the result from the select with the two cursor is with duplicate rows. So my question is how to iterate from two or more cursors in SQL Server as you must know that the two cursors are depend on each other.

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风透绣罗衣 2025-01-03 19:08:07

尝试在选择上进行区分,并且不会有重复的行。

select distinct ... from tablename

但为什么你需要两个光标呢?我强烈建议您更改该代码!

Try to make a distinct on the select and you don't have duplicate rows.

select distinct ... from tablename

But why in hell do you need two cursors? I strongly advise you to change that code!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文