Randomly extract N records SQL (MySQL and SQLServer)
MySQL: Select * from tablename Order by rand () limited 10sqlserver: select top 10 * from tablename Order by newid ()
In the eligible data, starting from article 5 Mysql: SELECT *WM TABLE LIMIT 5, 10SQLSERVER: SELECT TOP 10 * From Table Where (IdentityCol Not in (select Top 5 IdentityColfrom Table ORDER BY IDENTITYCOL) ) Order by IdentityCol
Or: Select *, Identity (int, 1, 1) AS NUM INTO ## aa from TableNameselectric * from ## aa where num> = 5 and num <= 10
Note:
IdentityCol returns the identity column. For more information, see Identity, ALTER TABLE, and CREATE TABLE. If there is a column containing the Identity property in the plurality of tables in the FROM clause, you must qualify Identitycol with a specific table name (such as t1.identitycol).
ROWGUIDCOL Returns the global unique identity column. If there are multiple tables in the FROM clause with the ROWGUIDCOL attribute, RowGuidCol must be qualified with a specific table name (such as t1.rowguidcol).