数据库技术,mysql,oracle
随机排序获取列表;
$sql="select * from article order by dbms_random.value()";
获取指定条数的数据:
$sql="select * from article where rownum<=$limit";
$sql1="select *,rownum rn from article";
$sql1="select * from ($sql1)s where s.rn<=$limit";
分组计数:
select category,count(*) count from article group by category;
分页获取列表数据:
$start=($page-1)*$perpage+1;
$end=$perpage*$page;
$sql="select * from article";
$sql="SELECT * FROM
(
select a.*,rownum row_num from($sql)a
)b
WHERE b.row_num between $start and $end";