Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the Equivalent syntax of mysql " LIMIT " clause in SQL Server

What is the Equivalent syntax of MySQL " LIMIT " clause in SQL Server . I would like to use it for doing paging of my results. (want to show records5 to 10 )

like image 267
Shyju Avatar asked Nov 15 '09 04:11

Shyju


1 Answers

The closest thing is TOP:

Select top 5 * from tablename

You can get a range ( rows 5 - 10)

SELECT * FROM (
  SELECT TOP n * FROM (
    SELECT TOP z columns      -- (z=n+skip)
    FROM tablename
    ORDER BY key ASC
  )
)
like image 178
Christian Payne Avatar answered Oct 10 '22 07:10

Christian Payne