SQL Server:
Copy codeThe Code is as follows:
Select top n * From TABLE Order By NewID ()
View plaincopy to clipboardprint?
Select top n * From TABLE Order By NewID ()
Select top n * From TABLE Order By NewID ()
The NewID () function creates a unique value of the uniqueidentifier type. The preceding statement reads N records randomly from the Table.
Access:
Copy codeThe Code is as follows:
Select top n * From TABLE Order By Rnd (ID)
View plaincopy to clipboardprint?
Select top n * From TABLE Order By Rnd (ID)
Select top n * From TABLE Order By Rnd (ID)
In Rnd (ID), the ID is an automatic number field, which can be completed using any other value, for example, the name field (UserName)
Copy codeThe Code is as follows:
Select top n * From TABLE Order BY Rnd (Len (UserName ))
View plaincopy to clipboardprint?
Select top n * From TABLE Order BY Rnd (Len (UserName ))
Select top n * From TABLE Order BY Rnd (Len (UserName ))
MySql:
Copy codeThe Code is as follows:
Select * From TABLE Order By Rand () Limit 10
View plaincopy to clipboardprint?
Select * From TABLE Order By Rand () Limit 10
Select * From TABLE Order By Rand () Limit 10
PostgreSQL:
Copy codeThe Code is as follows:
Select * from glxt022 order by random () limit 5
View plaincopy to clipboardprint?
Select * from glxt022 order by random () limit 5