How to use LIMIT keyword in SQL Server 2005?

后端 未结 3 683
忘掉有多难
忘掉有多难 2020-12-15 04:01

I have found a way to select random rows from a table in this post. A suggestion is to use the following query:

SELECT * FROM employee ORDER BY RAND() LIMIT          


        
3条回答
  •  南笙
    南笙 (楼主)
    2020-12-15 04:53

    SELECT TOP 1 * FROM Employee ORDER BY newid()
    

    You have to use newid() for it to be evaluated once per row.

提交回复
热议问题