I’m performing the following MySQL query inside phpmyadmin. The found_rows() function is not returning any result.
SELECT SQL_CALC_FOUND_ROWS `name` , `ability`
FROM `magic`
WHERE `name` LIKE 'Black%'
GROUP BY `name`
ORDER BY `name`
LIMIT 0 , 10;
SELECT FOUND_ROWS();
I’ve tried running the Select queries separately, one after another, but I get unexpected results. The first query alone returns 13 results, which is the correct total. When I run the found_rows() query afterwards, 20 is returned.
How can I get Found_rows() to report properly?
Thanks,
skibulk
You can’t, in PHPMyAdmin.
PHPMyAdmin uses the
FOUND_ROWS()itself to tell you how many rows were found in your last query, and parses this itself to tell you ‘x results found’.Every time you do a simple
SELECT, PHPMyAdmin adds a limit and executes this select, and the FOUND_ROWS afterwards to tell you how many results you would have found in without the LIMIT. This is how PHPMyAdmin offers paging (by default 30 elements), too.Plus, you cannot call
FOUND_ROWS()two times: the second time you call it, it will refer to the first time you called it. Since the first time returns 1 row, you get 1 as result.Do note also: by default each query you enter in PHPMyAdmin opens a new connection to MySQL, executes the query, and closes the connection. Your next query will not know of the first query, unless you put them all together in the input-textarea, separated by semicolons.
If you want to use FOUND_ROWS(), use another mysql-client. The
mysqlcommandline is fine: