Getting random values ​​from mysql

How to get RANDOM User_names.

SELECT a.mod_name, u.user_name, a.id from type a, users u WHERE a.id=u.mod_type ORDER BY mod_type Desc "; 
+4
source share
3 answers

What about

EDIT:

 select a.mod_name, u.user_name, a.id from type a, users u where a.id=u.mod_type order by mod_type DESC, rand(); 

?

+3
source

You can use ORDER BY RAND() to do this:

 SELECT a.mod_name, u.user_name, a.id FROM type a, users u WHERE a.id=u.mod_type ORDER BY RAND() 
+4
source

Mysql supports the RAND() function

  select a.mod_name, u.user_name, a.id from type a, users u where a.id=u.mod_type order by RAND(),mod_type Desc "; 
+2
source

Source: https://habr.com/ru/post/1446864/


All Articles