How universal is the LIMIT statement in SQL?

前端 未结 7 1895
予麋鹿
予麋鹿 2020-12-03 14:21

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

SELECT %s FROM %s LIMIT 1

to fetch 1 row and use

7条回答
  •  鱼传尺愫
    2020-12-03 14:47

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

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

    So, for you:

    SET ROWCOUNT 1
    SELECT %s FROM %s
    

提交回复
热议问题