---
title: "How to select random records from MySQL table?"  
description: "How to select random records from MySQL table?"  
author: "Anonymous User"  
published: 2012-03-10  
updated: 2012-03-12  
canonical: https://www.mindstick.com/forum/391/how-to-select-random-records-from-mysql-table  
category: "mysql"  
tags: ["mysql"]  
reading_time: 1 minute  

---

# How to select random records from MySQL table?

Hello Everyone,\
I'm facing a [problem](https://yourviews.mindstick.com/view/81399/tackling-the-problem-of-unemployment-during-corona-pandemic) since last night, actually I want to [select](https://www.mindstick.com/forum/160534/orderby-then-select-vs-select-then-orderby-performance) [records](https://www.mindstick.com/forum/34640/how-to-create-a-stored-procedure-for-display-all-records) from MySQL [table](https://www.mindstick.com/articles/43918/how-to-design-table-using-bootstrap) randomly. So [please tell me](https://www.mindstick.com/forum/33900/please-tell-me-what-are-the-technique-to-content-optimization) whether any [option](https://www.mindstick.com/forum/159391/jquery-get-selected-option-from-dropdown) in [MySQL database](https://answers.mindstick.com/qa/38302/what-is-the-main-difference-between-innodb-myisam-mysql-database-engines) to perform this action.\
\
Please reply as soon as possible.

## Replies

### Reply by Pravesh Singh

Hi Arun Singh,\
To select record from MySQLdatabase randomly, you can use ORDER BY RAND() function. This function returns table values randomly. You can use this as follows.\
\
Query: SELECT * FROM `table` ORDER BY RAND() ; \
\
You can also use this query to perform this action.\
\
Query: SELECT * FROM `table` ORDER BY RAND() LIMIT 2;\
where limit is used for random id limit.\
\
I hope this solution might be helpful for you.\


---

Original Source: https://www.mindstick.com/forum/391/how-to-select-random-records-from-mysql-table

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
