这篇文章主要为大家详细介绍了MySQL中统计查询结果总行数的便捷方法省去count(*),具有一定的参考价值,可以用来参考一下。
感兴趣的小伙伴,下面一起跟随四海网的小编小韵来看看吧!
MYSQL的关键词 :代码如下:
SELECT SQL_CALC_FOUND_ROWS tid FROM cdb_threads WHERE fid=14 LIMIT 1,10;
代码如下:
SELECT found_rows() AS rowcount;
代码如下:
function mail_list_sent( $uid, $start ) {
// 注意SQL_CALC_FOUND_ROWS uid之间没有逗号
$query = "SELECT SQL_CALC_FOUND_ROWS uid, real_name, current_city, msg_uid, sender_flag, ".
"msg_title, msg_content FROM " . TT_DBTABLEPRE . "mailbox as mb1, " . TT_DBTABLEPRE .
"user as usr1 WHERE mb1.sender_id=usr1.uid AND mb1.sender_id=$uid AND sender_flag > 0 LIMIT $start, " . TT_PAGESIZE;
$mails = $this->db->fetch_all( $query );
//查询SELECT中满足条件的行数,与LIMIT子句无关
$max_count = $this->db->fetch_first( "SELECT found_rows() AS rowcount" );
$tmp['state_code'] = 200;
$tmp['info'] = "OK";
$tmp['list'] = $mails;
$data = json_encode( $tmp );
return $data;
}
本文来自:http://www.q1010.com/177/9745-0.html
注:关于MySQL中统计查询结果总行数的便捷方法省去count(*)的内容就先介绍到这里,更多相关文章的可以留意四海网的其他信息。
关键词:MYSQL
四海网收集整理一些常用的php代码,JS代码,数据库mysql等技术文章。