mysql random order by

In special business scenarios, the data in the database needs to be queried randomly. MySQL has two solutions.

 

SELECT * FROM b_user ORDER BY id LIMIT 99,3 ;

 

SELECT * FROM b_user  ORDER BY RAND() LIMIT 3 ; 

 

The first is to obtain fixed data from random positions. The first 99 can be assigned by some other methods, and the latter is fixed.

The second is to use the rand function to obtain

 

Personally, I think the efficiency of the first one will be faster

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326196771&siteId=291194637