分页SQL

MySQL:
$limit = $page* $pagesize.",".$pagesize;
select *
from (select t1.*, t2.intro, t3.ul_size, t3.ul_name, t4.user_name
from work as t1
left join work_extra as t2 on t1.wid = t2.wid
join uploads as t3 on t1.wid = t3.ulid
join member as t4 on t1.uid = t4.uid
where t3.ul_type = '3'
and t1.status = '1') t
where wid in (1, 2, 3)
order by enjoyed desc limit 0, 6

Oracle:
//当前页起始游标
$startPoin = ($page-1)*$pagesize+1;
//当前页结束游戏标
$endPoin = $page*$pagesize;
select *
from (select row_number() over(order by a.Sub_Time desc) row_num,
a.action_id,
d.circle_id,
d.circle_image,
a.title,
to_char(a.start_time, 'yyyy-mm-dd') as start_time,
to_char(a.end_time, 'yyyy-mm-dd') as end_time,
a.view_count,
a.sub_time,
nvl(b.messagenum, 0) as messagenum,
nvl(c.joinnum, 0) as joinnum
from Action_Info a,
(select Action_ID, count(User_ID) as messagenum
from Action_Feedback
group by Action_ID) b,
(select Action_ID, count(User_ID) as joinnum
from Action_Join
group by Action_ID) c,
Circle_Info d
where a.Action_ID = b.Action_ID(+)
and a.Action_ID = c.Action_ID(+)
and a.circle_id = d.circle_id(+)
and a.User_ID = '$userID')
Where row_num between $startPoin And $endPoin
[img][/img][img][/img][img][/img][img][/img][img][/img]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值