如何一个接一个地从sql数据库中的表中获取下一条记录 [英] How to fetch the next records from a table in sql database one after other

查看:115
本文介绍了如何一个接一个地从sql数据库中的表中获取下一条记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序,我需要将电子邮件发送给表中的所有用户。由于用户数量是数百万,所以一次选择所有用户都不会有任何好处。有没有办法可以在20或30个用户中发送电子邮件,以便下次它能动态选择接下来的20个用户并发送电子邮件。任何帮助将不胜感激。

I am developing an application where I need to send the Emails to all the users in the table. Since the number of users is in millions, so to select all the users at once won’t do any good. Is there any way I can send emails in a group of 20 or 30 users so that the next time it will select the next 20 users dynamically and send emails. Any help will be appreciated.

推荐答案

从数据库中获取30个组中的记录将不是最佳选择。要优化此连接和网络开销,请使用单个查询获取所有数据。将此数据放入DataTable。



在DataTable中循环播放30个小组,获取电子邮件ID并发送邮件,然后继续下一个30。
It will not be optimal for you to fetch records in groups of 30 from the database. To optimize this connection and network overhead, get all data using a single query. Put this data in a DataTable.

Loop through groups of 30 in the DataTable, get the email ids and send mails before proceeding with the next 30.


这篇关于如何一个接一个地从sql数据库中的表中获取下一条记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆