日期:2014-05-18  浏览次数:20390 次

随机取记录问题
文章表
从随机栏目下随机取几条符合条件的记录
求高效写法


数据库是mysql的,但是没人回答,到这边试试

------解决方案--------------------
SQL code
select
 a.* 
from
 `user` as a
where
 (select count(1) from `user`  where name >= a.name and id=a.id) <=2
order by
 rand();