如何在使用SQL Server的条件中给出更多值

编程入门 行业动态 更新时间:2024-10-28 22:23:15
本文介绍了如何在使用SQL Server的条件中给出更多值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

亲爱的所有人, 我有一个十万的政策,我必须一次为所有一万个政策选择数据。如何通过使用sql server查询来完成这项工作。 例如, 从政策中选择* 其中policy_no in(1,2 ,3,4,..... 100000)。 请帮我解决这个问题。 我的尝试:

Dear All, I have one lakh policy nos, I have to select the data for all one lakh policies at a time. How can i get this done by using sql server query. For example, select * from policy where policy_no in (1,2,3,4,.....100000). Please help me to resolve this issue. What I have tried:

Dear All, I have one lakh policy nos, I have to select the data for all one lakh policies at a time. How can i get this done by using sql server query. For example, select * from policy where policy_no in (1,2,3,4,.....100000). Please help me to resolve this issue.

推荐答案

如果允许的政策号码不是范围(从1到X) )然后我会建议为允许的数字创建一个表并在查询中使用它。 例如 表AllowedPolicyNo If the allowed policy numbers is not a range (from 1 to X) then I would suggest creating a table for allowed numbers and using that in your query. For example Table AllowedPolicyNo - 1 - 15 - 18...

和查询

And the query

select * from policy p where p.policy_no in (select apn.policy_no from allowedpolicyno apn).

如果您愿意,可以使用连接

Or you can use a join if you prefer that

检查一下: SQL Server 2012 - 分页介绍 [ ^ ]

更多推荐

如何在使用SQL Server的条件中给出更多值

本文发布于:2023-10-14 11:27:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1490940.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:条件   更多   如何在   Server   SQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!