Why does FOUND_ROWS () return an incorrect result for SQL version 5.7.17?

I executed the following query on the local system

SELECT FOUND_ROWS() FROM table_name LIMIT 1; SQL Version : 5.6.16 

It returns the number of rows.

when the same query is launched on the server (SQL Version: 5.7.17), it returns 0.

After searching the Internet, people are advised to use

SQL_CALC_FOUND_ROWS

so I use the following query on both local and server.

 SELECT SQL_CALC_FOUND_ROWS * FROM users SELECT FOUND_ROWS(); 

But the results are the same, it works fine on the local (SQL version: 5.8.16) and returns 0 on the server (SQL version: 5.7.17).

+5
source share
1 answer

This is a mysql error that may be responsible for this problem, depending on the version you are using:

http://bugs.mysql.com/bug.php?id=1468

You can get around this by using the GROUP BY clause in your query. In my case, it works well.

+1
source

Source: https://habr.com/ru/post/1276013/


All Articles