如何将python循环i传递到sql选择顶部i行数
我知道我是Python和SQL Bear的新手。
我想运行一个查询,在Python编译器中运行SQL时,我可以在其中获得顶部(循环变量)。
例如
For I in range(1,5) :
Query = " Select top" I" * from sales"
,这可以在第一个i循环中获得第一行,并在接下来的我循环并继续前进。请协助。
I am new to python and sql bear with my knowledge.
I want to run a query where I can get top (looped variable) while running sql in python compiler.
Eg
For I in range(1,5) :
Query = " Select top" I" * from sales"
So that can get the top 1st row in first I loop and top 2nd row in next I loop and goes on. Please assist.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将替换字符串替换为准备的语句将无效
You use string replacement as prepared statements will not work