1
drop table if exists t1,t2;
2
create table t1 (a int not null auto_increment, b int not null, primary key(a));
3
insert into t1 (b) values (2),(3),(5),(5),(5),(6),(7),(9);
4
select SQL_CALC_FOUND_ROWS * from t1;
17
select SQL_CALC_FOUND_ROWS * from t1 limit 1;
23
select SQL_BUFFER_RESULT SQL_CALC_FOUND_ROWS * from t1 limit 1;
29
select SQL_CALC_FOUND_ROWS * from t1 order by b desc limit 1;
35
select SQL_CALC_FOUND_ROWS distinct b from t1 limit 1;
41
select SQL_CALC_FOUND_ROWS b,count(*) as c from t1 group by b order by c desc limit 1;
47
select SQL_CALC_FOUND_ROWS * from t1 left join t1 as t2 on (t1.b=t2.a) limit 2,1;
54
create table t1 (a int not null primary key);
55
insert into t1 values (1),(2),(3),(4),(5);
56
select sql_calc_found_rows a from t1 where a in (1,2,3) order by a desc limit 0,2;
63
select sql_calc_found_rows a from t1 where a in (1,2,3) order by a+2 desc limit 0,2;
72
`id` smallint(5) unsigned NOT NULL auto_increment,
73
`kid` smallint(5) unsigned NOT NULL default '0',
78
id smallint(5) unsigned NOT NULL auto_increment,
79
name varchar(50) NOT NULL default '',
80
email varchar(50) NOT NULL default '',
82
UNIQUE KEY e_n (email,name)
84
EXPLAIN SELECT SQL_CALC_FOUND_ROWS DISTINCT email FROM t2 LEFT JOIN t1 ON kid = t2.id WHERE t1.id IS NULL LIMIT 10;
85
id select_type table type possible_keys key key_len ref rows Extra
86
1 SIMPLE t1 system PRIMARY,kid NULL NULL NULL 0 const row not found
87
1 SIMPLE t2 index NULL e_n 104 NULL 10
88
SELECT SQL_CALC_FOUND_ROWS DISTINCT email FROM t2 LEFT JOIN t1 ON kid = t2.id WHERE t1.id IS NULL LIMIT 10;
103
SELECT SQL_CALC_FOUND_ROWS DISTINCT email FROM t2 LEFT JOIN t1 ON kid = t2.id WHERE t1.id IS NULL order by email LIMIT 10;
118
SELECT DISTINCT email FROM t2 LEFT JOIN t1 ON kid = t2.id WHERE t1.id IS NULL LIMIT 10;
130
SELECT DISTINCT email FROM t2 LEFT JOIN t1 ON kid = t2.id WHERE t1.id IS NULL ORDER BY email LIMIT 10;
142
INSERT INTO `t1` (`id`, `kid`) VALUES ('0', '150');
143
SELECT SQL_CALC_FOUND_ROWS DISTINCT email FROM t2 LEFT JOIN t1 ON kid = t2.id WHERE t1.id IS NULL LIMIT 10;
160
`titre` char(80) NOT NULL default '',
161
`numeropost` mediumint(8) unsigned NOT NULL auto_increment,
162
`maxnumrep` int(10) unsigned NOT NULL default '0',
163
PRIMARY KEY (`numeropost`),
164
KEY `maxnumrep` (`maxnumrep`)
165
) ENGINE=MyISAM ROW_FORMAT=FIXED;
166
INSERT INTO t1 (titre,maxnumrep) VALUES
167
('test1','1'),('test2','2'),('test3','3');
168
SELECT SQL_CALC_FOUND_ROWS titre,numeropost,maxnumrep FROM t1 WHERE numeropost IN (1,2) ORDER BY maxnumrep DESC LIMIT 0, 1;
169
titre numeropost maxnumrep
174
SELECT SQL_CALC_FOUND_ROWS 1 FROM (SELECT 1) as a LIMIT 0;
179
SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE numeropost > 1 LIMIT 0;
180
titre numeropost maxnumrep
184
SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 0;
185
titre numeropost maxnumrep
189
SELECT SQL_CALC_FOUND_ROWS * FROM t1 ORDER BY numeropost LIMIT 0;
190
titre numeropost maxnumrep
195
create table t1 (id int, primary key (id));
196
insert into t1 values (1), (2), (3), (4), (5);
197
select SQL_CALC_FOUND_ROWS * from t1 where id > 3 limit 0, 1;
203
select SQL_CALC_FOUND_ROWS * from t1 where id > 3 AND 1=2 limit 0, 1;
208
select SQL_CALC_FOUND_ROWS * from t1 where id > 6 limit 0, 1;
214
CREATE TABLE t1 ( a int not null, b int not null, KEY ab(a,b) );
215
INSERT INTO t1 VALUES ( 47, 1 );
216
INSERT INTO t1 VALUES ( 70, 1 );
220
( b =1 AND a BETWEEN 14 AND 21 ) OR
221
( b =2 AND a BETWEEN 16 AND 18 ) OR
222
( b =3 AND a BETWEEN 15 AND 19 )
226
CREATE TABLE t1 ( a integer, u varchar(15), r integer, key uao_idx( r, a, u));
228
WHERE ( r = 1 AND a IN ( 1, 2 ) AND ( u = 'w' OR u LIKE 'w/%' ) )
229
OR ( r = 1 AND a IN ( 3 ) AND ( u = 'w/U' OR u LIKE 'w/U/%' ) )
230
OR ( r = 1 AND a IN ( 1, 2, 3 ) AND ( u = 'w' ) );
232
CREATE TABLE t1 (a VARCHAR(16), UNIQUE(a));
233
INSERT INTO t1 VALUES ('1'), ('2'), ('3');
234
SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE a = '2' LIMIT 0, 1;
241
CREATE TABLE t1 (a INT);
242
INSERT INTO t1 VALUES (0), (0), (1), (2);
243
SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE a = 0 GROUP BY a HAVING a > 10;
255
SELECT SQL_CALC_FOUND_ROWS 'foo';
261
SELECT SQL_CALC_FOUND_ROWS 'foo' limit 0;
269
SELECT SQL_CALC_FOUND_ROWS 'foo' UNION SELECT 'bar' LIMIT 0;
274
CREATE TABLE t1 (a int, b int);
275
INSERT INTO t1 VALUES (1,2), (1,3), (1,4), (1,5);
276
SELECT SQL_CALC_FOUND_ROWS DISTINCT 'a' FROM t1 GROUP BY b LIMIT 2;