string wheresql = " and c.id >= (select min(id) from (select id from caiji order by id desc limit 0,4000) as t) ";
sql = "select count(*) from caiji as c where 1 " + wheresql + consql;
sql = "select c.id as id, c.cid as cid, l.ctitle as leibie, c.ctitle as ctitle, c.cdate as cdate, c.url as url, c.cjdate as cjdate, c.zhtitle as zhtitle from caiji as c join leibie as l where 1 " + wheresql + " and c.cid = l.cid " + consql + " order by c.id desc limit " + (curpage - 1) * perpage + "," + perpage;
select id from caiji where id <= (select min(id) from ( select id from caiji where cid=5 order by id desc limit 10000,1 ) as t) and cid=5 order by id desc limit 0,10
其中,10000为总记录数,为第几页页数*每页记录数
sql = "select count(*) from caiji as c join (select id from caiji order by id desc limit 0, 10000 ) as b on c.id = b.id where 1 " + consql;
else
{
sql = "select count(*) from caiji ";
}
if (Request.QueryString["cid"] != null && Request.QueryString["cid"].Length > 0)
{
tmpsql = "select id from caiji where id <= (select min(id) from ( select id from (select c.id from caiji as c join (select id from caiji order by id desc limit 0, 10000 ) as b on c.id = b.id where 1 " + consql + " ) as p order by id desc limit " + (curpage - 1) * perpage + ",1 ) as t) order by id desc limit 0," + perpage;
sql = "select c.id as id, c.cid as cid, l.ctitle as leibie, c.ctitle as ctitle, c.cdate as cdate, c.url as url, c.cjdate as cjdate, c.zhtitle as zhtitle from caiji as c join leibie as l on c.cid = l.cid right join (" + tmpsql + ") as r on r.id = c.id";
//Response.Write(sql + "<br>");
}else
{
tmpsql = "select id from caiji where id <= (select min(id) from ( select id from caiji order by id desc limit " + (curpage-1)*perpage + ",1 ) as t) order by id desc limit 0," + perpage;
sql = "select c.id as id, c.cid as cid, l.ctitle as leibie, c.ctitle as ctitle, c.cdate as cdate, c.url as url, c.cjdate as cjdate, c.zhtitle as zhtitle from caiji as c join leibie as l on c.cid = l.cid right join (" + tmpsql + ") as r on r.id = c.id";
}