14 March 2012

[mysql ] perform order by column and rand() in single query

SELECT * FROM
(
    SELECT * FROM table1
    ORDER BY nos desc limit 0,1) 
          )  T1 ORDER BY RAND()
 
 
 
 
usage: 
if the column nos is same in multipe rows then fetch a random row..



No comments:

Post a Comment