添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
select count(*) as total from foods_info LIMIT 0,10;
select count(*) as total from foods_info;

缺点: 记录集还需要单独的查询来获取,相当于两次查询

2、推荐方法

select SQL_CALC_FOUND_ROWS * from foods_info LIMIT 0,10;
SELECT FOUND_ROWS() as total;

虽然看起来是两条SQL语句,但是实际上只执行了一次数据库查询。