0

How to List a Specific number of Random Rows in MySQL

Background

Let’s say you have a list of 10 items you want to display but these items are randomly chosen items. In MySQL, you use the rand() function in the ORDER BY clause. This article demonstrates how to list a specific number of random rows my MySQL.

Software Environment

  • Windows 7 Professional SP1
  • MySQL 5.6.16 – Community Server (GPL)

The SQL Statement

This returns a new set of 10 records every time it is executed.

Karl San Gabriel

Karl San Gabriel

Java and Enterprise Technologies Expert