SELECT cid, CONCAT(firstname, ' ', surname), COUNT(call_id) FROM t1 LEFT JOIN t2 ON cid=contact_id WHERE firstname like '%foo%' GROUP BY cid ORDER BY NULL;
SELECT cid, CONCAT(firstname, ' ', surname), COUNT(call_id) FROM t1 LEFT JOIN t2 ON cid=contact_id WHERE firstname like '%foo%' GROUP BY cid ORDER BY surname, firstname;
108
SELECT HIGH_PRIORITY cid, CONCAT(firstname, ' ', surname), COUNT(call_id) FROM t1 LEFT JOIN t2 ON cid=contact_id WHERE firstname like '%foo%' GROUP BY cid ORDER BY surname, firstname;
Warning 1071 Specified key was too long; max key length is 767 bytes
546
566
insert into t2 select
547
567
x3.a, -- 3
548
568
concat('val-', x3.a + 3*x4.a), -- 12
552
572
delete from t2 where a = 2 and b = 'val-2' order by a,b,c,d limit 30;
553
573
explain select c from t2 where a = 2 and b = 'val-2' group by c;
554
574
id select_type table type possible_keys key key_len ref rows Extra
555
1 SIMPLE t2 # PRIMARY,a a # const,const # #
575
1 SIMPLE t2 ref PRIMARY,a a 770 const,const 36 Using where; Using index
556
576
select c from t2 where a = 2 and b = 'val-2' group by c;
557
577
c
558
578
val-74
895
915
f1 f2
896
916
select * from t1 group by f1, f2;
897
917
f1 f2
898
select t1.f1,t.* from t1, t1 t where t1.f1 >= 0 group by 1;
918
select t1.f1,t.* from t1, t1 t group by 1;
899
919
f1 f1 f2
900
920
drop table t1;
901
921
CREATE TABLE t1(
1344
1364
id select_type table type possible_keys key key_len ref rows Extra
1345
1365
1 SIMPLE t1 index NULL PRIMARY 4 NULL 144
1346
1366
EXPLAIN SELECT a FROM t1 FORCE INDEX ();
1347
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use near ')' at line 1
1367
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
1348
1368
EXPLAIN SELECT a FROM t1 IGNORE INDEX ();
1349
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use near ')' at line 1
1369
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
1350
1370
EXPLAIN SELECT a FROM t1 USE INDEX FOR JOIN (i2)
1351
1371
USE INDEX FOR GROUP BY (i2) GROUP BY a;
1352
1372
id select_type table type possible_keys key key_len ref rows Extra
1376
1396
EXPLAIN SELECT 1 FROM t1 WHERE a IN
1377
1397
(SELECT a FROM t1 USE INDEX (i2) IGNORE INDEX (i2));
1378
1398
id select_type table type possible_keys key key_len ref rows Extra
1379
1 PRIMARY t1 index NULL PRIMARY 4 NULL 144 Using where; Using index