카테고리: Database

In this article, introduce how to extract random data effectively from MySQL table. Many solutions in stackoverflow are very slow or inefficient.
Select Random Id
SELECT ROUND(RAND()*(SELECT COUNT(*) FROM table_name)) AS id;
At first, we can create random id which is in your table table_name.
Select Random Id List
And then, by using this,
SELECT ROUND(RAND()*(SELECT COUNT(*) FROM table_name)) AS id FROM table_name LIMIT 100;
We can get 100 random id from this SQL.
If you want to get ...