BKJIA quick translation: what is the use of random row extraction from database tables? Because sometimes you want to present random information to users. The following describes how to extract random row code from several popular databases. BKJIA Editor: BKJIA has introduced methods for reading random data, including ASP.. NET 2.0 randomly reads Access database records, MySQL extracts random data from the table, and the method to obtain random numbers in ORACLE)
MySQL extracts 10 random rows
SELECT column FROM table Order by rand () LIMIT 10 |
Extract 10 random rows from Oracle
SELECT column FROM ( SELECT column FROM table ORDER BY dbms_random.value ) WHERE rownum <= 10
|
Extract 10 random rows from PostgreSQL
SELECT column FROM table ORDER BY RANDOM() LIMIT 10
|
Extract 10 random rows from Microsoft SQL Server
SELECT TOP 10 column FROM table ORDER BY NEWID()
|
Code Source: viralpatel.net
- Access database records are randomly read in ASP. NET 2.0.
- MySQL extracts random data from the table
- Method for obtaining random numbers in ORACLE