jeudi 25 août 2016

Is there a query to select random row from a set of returned rows from a SELECT statement in sql?

Suppose a SELECT query returns 10 rows. Is there any one line query such as this (which I tried but did not work) to select one random row from return results of a SELECT query -

select name from (select * my_table where age > 10 AS rows)
ORDER BY RAND() LIMIT 1;




Aucun commentaire:

Enregistrer un commentaire