The NewID () method returns a GUID, such as: Ee95a489-b721-4e8a-8171-3ca8cb6ad9e4
In the Select table, add another column to NewID ().
SQL statement: SELECT *, NewID () from table
So after each record there will be a random GUID value, and we can follow this GUID row order to achieve the effect of disorderly order.
SQL statement: SELECT *, NewID () as random from table order by random
We want to randomly take out 10 data, just add TOP 10 on the line:
SQL statement: Select Top *, NewID () as random from table order by random
Filter Unique Records
SELECT * FROM TableName ORDER by NEWID ()
This method applies only to SQL Server.
SELECT Top 4 * from Table ORDER by Rnd (ID)
This sentence applies to access, you can refer to
SELECT * FROM table_name ORDER BY RAND () [Limit num];
MySQL's random query statement.
How to randomly extract a data from a database table in SQL statements