如果没有两个选择,有没有办法做到这一点?
原始查询
SELECT name,view_count
FROM `ex`.`item`
where status='available' order by view_count asc
limit 40;
随机显示
SELECT *
FROM (SELECT name,view_count
FROM `ex`.`item`
where status='available'
order by view_count asc
limit 40 ) AS temp
ORDER BY RAND();
这可以在没有第二次选择的情况下完成吗?
答案 0 :(得分:1)
试试这个:
SQL小提琴:http://sqlfiddle.com/#!2/330f8/2
SELECT name, view_count
FROM `ex`.`item`
where status='available'
order by rand(), view_count asc limit 40;