平成30/ 2018-12-10 16:39
MYSQL/ found_rows(), 件数

select
    sql_calc_found_rows
    *
from sample_tbl
limit 0, 5
;

select found_rows();
----------|


|
| DISTINCTも評価されまする。
|----------
select sql_calc_found_rows distinct email from ios_token limit 300, 100;
select found_rows();
+--------------+
| found_rows() |
+--------------+
|          394 |
+--------------+
----------|




(Thanks.)
mysql 件数 合計 FOUND_ROWSとSQL_CALC_FOUND_ROWSを使う
http://webcache.googleusercontent.com/search?q=cache:1FHpJT_adx0J:ma-bank.com/item/998+mysql+%E4%BB%B6%E6%95%B0&cd=1&hl=ja&ct=clnk&gl=jp&client=firefox-a&source=www.google.co.jp
$query = 'SELECT SQL_CALC_FOUND_ROWS id, name, area FROM company ORDER BY id LIMIT 20'; //SQLクエリは1つだけ
$result3 = mysql_query($query);
$num_query = mysql_query('SELECT FOUND_ROWS()');
list($num) = mysql_fetch_row($num_query);
switch($num) {
case "" :
echo "Not Found.";
break;
default :
echo "<h2>次の20件を含め、全体では ".$num." 件あります。</h2>";
while($r3 = mysql_fetch_assoc($result3)) {
  echo htmlspecialchars($r3['id']." ".$r3['name']." ".$r3['area'], ENT_QUOTES, "UTF-8")."<br />";
}
}