mysql分页同时取出总记录数

select *,(SELECT count(1) from snatchorderinfo WHERE InfoSource =1) as cnt 
from snatchorderinfo 
where InfoSource =1 limit 5,3;

 

另一种方式,这个不适合在代码里使用

select sql_calc_found_rows InfoSource 
from snatchorderinfo 
WHERE InfoSource =1 limit 5,3;
select found_rows()

 

你可能感兴趣的:(数据库)