Questions tagged [sql-calc-found-rows]
31 questions
24
votes
7 answers
How to use MySQL Found_Rows() in PHP?
I try to avoid doing Count() because of performance issue. (i.e. SELECT COUNT() FROM Users)
If I run the followings in phpMyAdmin, it is ok:
SELECT SQL_CALC_FOUND_ROWS * FROM Users;
SELECT FOUND_ROWS();
It will return # of rows. i.e. # of…

murvinlai
- 48,919
- 52
- 129
- 177
13
votes
3 answers
Mysql SQL_CALC_FOUND_ROWS and pagination
So I have a table that has a little over 5 million rows. When I use SQL_CALC_FOUND_ROWS the query just hangs forever. When I take it out the query executes within a second withe LIMIT ,25. My question is for pagination reasons is there an…

John
- 9,840
- 26
- 91
- 137
10
votes
4 answers
MySQL / PDO FOUND_ROWS() sometimes falsely returning 0
We have a laravel 4.1 application that used to run under PHP 5.4, however since upgrading to 5.6.13 (And today to 5.6.14) I've noticed that queries have started to sometimes return 0 for FOUND_ROWS(). On some of our queries it seems to be…

BenOfTheNorth
- 2,904
- 1
- 20
- 46
6
votes
1 answer
How to disable or circumvent phpmyadmin's SQL_CALC_FOUND_ROWS
When you process a SELECT through phpmyadmin, behind the scenes, it will sometimes add a LIMIT 0,30, and/or it'll throw a SQL_CALC_FOUND_ROWS into the SELECT so it can tell me how many results there would have been without the LIMIT.
Unfortunately,…

Riedsio
- 9,758
- 1
- 24
- 33
6
votes
2 answers
How to get the SQL_CALC_FOUND_ROWS value using prepared statements?
I'm currently scratching my head at how to implement SQL_CALC_FOUND_ROWS with prepared statements.
I'm writing a pagination class and obviously i want to add LIMIT to the query but also find what the total number of rows would be.
Here's an example…

cosmicsafari
- 3,949
- 11
- 37
- 56
5
votes
1 answer
Why FOUND_ROWS() returns wrong result for 5.7.17 SQL version?
I have run following query on local system
SELECT FOUND_ROWS() FROM table_name LIMIT 1;
SQL Version : 5.6.16
It returns number of rows.
when same query run on server(SQL Version : 5.7.17) it return 0.
After searching on internet people suggest to…

hu7sy
- 983
- 1
- 13
- 47
3
votes
3 answers
Wrong result with FOUND_ROWS() in mySQL
I have a total of 6 rows. When I do a query (say SELECT * from table) and I have
LIMIT 3 => FOUND_ROWS() gives 3 => 3 rows is retrieved
LIMIT 1, 3 => FOUND_ROWS() gives 4 => 3 rows is retrieved
LIMIT 2, 3 => FOUND_ROWS() gives 5 => 3 rows is…

Nyxynyx
- 61,411
- 155
- 482
- 830
3
votes
1 answer
MySQL/MariaDB FOUND_ROWS returns 1 even if no rows were returned
I'm running MariaDB version 5.5.56 and seem to be experiencing a bug: FOUND_ROWS() returns '1' after a SELECT which returns zero rows.
According to bug report 83110, MySQL had this problem as of version 5.7.15, but appears to be a closed issue, so I…

Ryan Griggs
- 2,457
- 2
- 35
- 58
2
votes
1 answer
Codeigniter+MySql: Integrate COUNT into this query to avoid double queries when paginating
Since pagination in Codeigniter (IMHO) lack some good stuff for easier implementation when using filters (beginning letter, category, etc.), even though my pagination is fully functional and working - i have two queries running and the only…

developer10
- 1,450
- 2
- 15
- 31
2
votes
2 answers
SQL_CALC_FOUND_ROWS with FOUND_ROWS always returns 1
select SQL_CALC_FOUND_ROWS, col1 , mytable.id from mytable group by col1;
select found_rows();
select found_rows() , col1 , mytable.id from mytable group by col1;
This above query always results 1 for found rows. I am using php 7.1 and maria db…

sai sanath
- 51
- 1
- 8
2
votes
2 answers
MySql SQL_CALC_FOUND_ROWS issue in FULL-TEXT search
I am trying to add pagination to my results which query a FULL-TEXT indexed table. Here is the query:
Normal Query
SELECT *,MATCH(title) AGAINST ("+samsung +galaxy +s3" IN BOOLEAN MODE)
as score FROM `deals` WHERE `image`!='' AND category=15032…

web-nomad
- 6,003
- 3
- 34
- 49
1
vote
1 answer
Java, prepareStatement, SQL_CALC_FOUND_ROWS, FoundRows() hows it work
I'm trying to do pagination from the db and so far I have found that if you want to use limit you should use SQL_CALC_FOUND_ROWS.
However, in Java I'm having some issues understanding how to call this.
Can I do it in one prepareStatement or will I…

MrB
- 1,544
- 3
- 18
- 30
1
vote
2 answers
Value return incorrectly after calculated field
SELECT
t3.id,
t3.prod_ID,
MIN(diff) AS min_time
FROM
(SELECT
t1.id,
(UNIX_TIMESTAMP(t2.time_stamp_2) - UNIX_TIMESTAMP(t1.time_stamp)) AS diff
FROM
production t1
LEFT JOIN
process t2 ON…

silver_river
- 169
- 1
- 10
1
vote
1 answer
Is SQL_CALC_FOUND_ROWS / select FOUND_ROWS() subject to race conditions?
According to this answer: here
The use of SQL_CALC_FOUND_ROWS is not subject to race conditions. The
result of the SELECT query, yes, but not the result of FOUND_ROWS().
Don't confuse this.
But from all the queries I have ran it is…

Taylor Austin
- 5,407
- 15
- 58
- 103
1
vote
1 answer
MySQL - ORDER BY clause causing SQL_CALC_FOUND_ROWS select to not return data
I am using MySQL 5.6 on a centos 6 box (mysql Ver 14.14 Distrib 5.6.44, for Linux (i686) using EditLine wrapper)
I have a query with multiple inner joins. I have identified that when using a ORDER BY clause with SQL_CALC_FOUND_ROWS no data is…

travis wilder
- 129
- 1
- 8