How can you sort if you only fetch one piece of data... Just randomly fetch one piece and that's it. Upstairs, if you need to fetch multiple pieces, you need to sort them with one layer of sql. select * from (select * from a order by rand() limit n) aa order by b desc;
select * from a order by b desc
The front of the returned result set has a higher weight
For example
If you don’t have much data
select *from a order by rand() limit 1
How can you sort if you only fetch one piece of data... Just randomly fetch one piece and that's it. Upstairs, if you need to fetch multiple pieces, you need to sort them with one layer of sql.
select * from (select * from a order by rand() limit n) aa order by b desc;