MySQL select 10 random rows from 600K rows fast

后端 未结 26 2913
粉色の甜心
粉色の甜心 2020-11-21 05:06

How can I best write a query that selects 10 rows randomly from a total of 600k?

26条回答
  •  情歌与酒
    2020-11-21 05:27

    Use the below simple query to get random data from a table.

    SELECT user_firstname ,
    COUNT(DISTINCT usr_fk_id) cnt
    FROM userdetails 
    GROUP BY usr_fk_id 
    ORDER BY cnt ASC  
    LIMIT 10
    

提交回复
热议问题