本文介绍了LIMIT语句在SQL中的通用性如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在推广一个Django数据库复制应用程序,它使用以下语句:

I'm in the process of generalizing a Django DB replication app and it uses the statement:

SELECT %s FROM %s LIMIT 1

取得1列,并使用Python DBAPI描述栏位,与ORACLE和MySQL,但是,如何跨平台是LIMIT语句?

to fetch 1 row and use the Python DBAPI to describe the fields, it works fine with ORACLE and MySQL but, how cross platform is the LIMIT statement?

推荐答案

列出了所有主要版本的select命令。

http://en.wikipedia.org/wiki/Select_(SQL)#Result_limits lists all of the major variants of the select command.

我相信最好的方法是在SELECT语句之前使用SET ROWCOUNT命令。

I believe the best way to do this is to use the SET ROWCOUNT command before your SELECT statement.

所以,为你:

SET ROWCOUNT 1
SELECT %s FROM %s

这篇关于LIMIT语句在SQL中的通用性如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 15:41
查看更多