Home > database >  Mysql mobile terminal paging
Mysql mobile terminal paging

Time:09-24

Mobile end every page of the last article in the current page ID and I will according to order after take this ID a few, the original is essentially a lane, mysql with as, rownumer, is written like this:
Select * from (
Select @ rownum:=@ + 1 AS rownum, rownum s.c bgs_create_time, s.c bgs_id from (select @ rownum:=0) t, cs_biz_goods_source s
The order by s.c bgs_create_time desc
Qt)
Where qt. Rownum & gt;
(
Select rownum clause (
Select @ rownum:=@ + 1 AS rownum, rownum s.c bgs_create_time, s.c bgs_id from (select @ rownum:=0) t, cs_biz_goods_source s
The order by s.c bgs_create_time desc
='75) temp where cbgs_id d5e99d2f08480ead7d74f3c3990962'
)

But qt. Rownum & gt; The subquery this condition is empty, found out the structure of direct write qt. Rownum & gt; 7 can be found out, I found out the following sub queries to the rownum is 7 pages, this is because the mysql mechanism

CodePudding user response:

(
Select rownum clause (
Select @ rownum:=@ + 1 AS rownum, rownum s.c bgs_create_time, s.c bgs_id from (select @ rownum:=0) t, cs_biz_goods_source s
The order by s.c bgs_create_time desc
='75) temp where cbgs_id d5e99d2f08480ead7d74f3c3990962'
)
This long whether can be rewritten to:
The select couont (*) from cs_biz_goods_source where cbgs_id='75 d5e99d2f08480ead7d74f3c3990962';
You don't just want to ask how many records?

CodePudding user response:

Select @ rownum:=@ + 1 as rownum, rownum - line number
* * *
The from cs_biz_goods_source a,
B: (select @ rownum=0)
Where a.c bgs_id='75 d5e99d2f08480ead7d74f3c3990962'
And a.c bgs_create_time & lt; Ifnull (a.c bgs_create_time, '2050-01-01') -- back the last value, if you give a default value is empty, can
The order by a.c bgs_create_time desc
limit 20; - each page shows article 20

  • Related