SQL 服务器中是否有等效的 MYSQL "LIMIT" 子句?

Is there an equivalent MYSQL "LIMIT" Clause in SQL Server?

我的分页代码在MySQLreturns查询中用了LIMIT(SELECT * FROM tableTest LIMIT $start, $display)来显示当前行。

有没有办法在 SQL 服务器中实现这种逻辑?

MSSQL中你需要使用FETCH-OFFSET

<offset_fetch> ::=
{ 
    OFFSET { integer_constant | offset_row_count_expression } { ROW | ROWS }
    [
      FETCH { FIRST | NEXT } {integer_constant | fetch_row_count_expression } { ROW | ROWS } ONLY
    ]
}

来自 MSDN

OFFSET { integer_constant | offset_row_count_expression } { ROW | ROWS } Specifies the number of rows to skip before it starts to return rows from the query expression. The value can be an integer constant or expression that is greater than or equal to zero.

FETCH { FIRST | NEXT } { integer_constant | fetch_row_count_expression } { ROW | ROWS } ONLY Specifies the number of rows to return after the OFFSET clause has been processed. The value can be an integer constant or expression that is greater than or equal to one.