select *
from
表名 as t1
join (
select
round(
rand() * ((select max( id ) from 表名 ) - ( select min( id ) from 表名 )) + ( select min( id ) from 表名 )) as id
) as t2
where
t1.id >= t2.id
order by
t1.id
limit 1
MySQL数据库随机抽取一条记录(不用order by rand())
于 2024-01-08 21:18:48 首次发布