I need a MySql statement that will select all rows as well as the number of volumes.
Literally, this is not possible. The result of the SQL query is a (virtual) table; the column in each row in this result table contains a value that is associated only with that row, and the rows act independently of each other.
rowcount , , , , . ( )
, :
:
( )
. , COUNT (*) , - MySql ? .
COUNT . , . , mysql SELECT. , , , MySQL .
COUNT (*) , .
, , , . !
, .
, PHP, , MySQL limit, php mysql_num_rows (http://www.php.net/manual/en/function.mysql-num-rows.php) mysql_query.
, LIMIT, 2 : -, , , MySQL FOUND_ROWS. (. http://dev.mysql.com/doc/refman/5.5/en/information-functions.html#function_found-rows)
:
$result = mysql_query('SELECT SQL_CALC_FOUND_ROWS * FROM posts LIMIT 0, 5');
//do stuff with the result, but don't do any other queries
//get the total number of rows (disregarding the LIMIT clause)
$result = mysql_query('SELECT FOUND_ROWS()');
SQL_CALC_FOUND_ROWS MySQL LIMIT, FOUND_ROWS() . :
, : LIMIT , . LIMIT . , , , LIMIT . , ORDER BY. (http://dev.mysql.com/doc/refman/5.5/en/select.html)