Randomly extract rows from database tables

Source: Internet
Author: User

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

  1. Access database records are randomly read in ASP. NET 2.0.
  2. MySQL extracts random data from the table
  3. Method for obtaining random numbers in ORACLE

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.