~vadim-tk/percona-server/percona-galera-5.1.57

« back to all changes in this revision

Viewing changes to mysql-test/r/select.result

  • Committer: root
  • Date: 2011-07-10 16:09:24 UTC
  • Revision ID: root@r815.office.percona.com-20110710160924-fyffqsbaclgu6vui
Initial port

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
drop table if exists t1,t2,t3,t4,t11;
 
2
drop table if exists t1_1,t1_2,t9_1,t9_2,t1aa,t2aa;
 
3
drop view if exists v1;
 
4
CREATE TABLE t1 (
 
5
Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
 
6
Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
 
7
);
 
8
INSERT INTO t1 VALUES (9410,9412);
 
9
select period from t1;
 
10
period
 
11
9410
 
12
select * from t1;
 
13
Period  Varor_period
 
14
9410    9412
 
15
select t1.* from t1;
 
16
Period  Varor_period
 
17
9410    9412
 
18
CREATE TABLE t2 (
 
19
auto int not null auto_increment,
 
20
fld1 int(6) unsigned zerofill DEFAULT '000000' NOT NULL,
 
21
companynr tinyint(2) unsigned zerofill DEFAULT '00' NOT NULL,
 
22
fld3 char(30) DEFAULT '' NOT NULL,
 
23
fld4 char(35) DEFAULT '' NOT NULL,
 
24
fld5 char(35) DEFAULT '' NOT NULL,
 
25
fld6 char(4) DEFAULT '' NOT NULL,
 
26
UNIQUE fld1 (fld1),
 
27
KEY fld3 (fld3),
 
28
PRIMARY KEY (auto)
 
29
);
 
30
select t2.fld3 from t2 where companynr = 58 and fld3 like "%imaginable%";
 
31
fld3
 
32
imaginable
 
33
select fld3 from t2 where fld3 like "%cultivation" ;
 
34
fld3
 
35
cultivation
 
36
select t2.fld3,companynr from t2 where companynr = 57+1 order by fld3;
 
37
fld3    companynr
 
38
concoct 58
 
39
druggists       58
 
40
engrossing      58
 
41
Eurydice        58
 
42
exclaimers      58
 
43
ferociousness   58
 
44
hopelessness    58
 
45
Huey    58
 
46
imaginable      58
 
47
judges  58
 
48
merging 58
 
49
ostrich 58
 
50
peering 58
 
51
Phelps  58
 
52
presumes        58
 
53
Ruth    58
 
54
sentences       58
 
55
Shylock 58
 
56
straggled       58
 
57
synergy 58
 
58
thanking        58
 
59
tying   58
 
60
unlocks 58
 
61
select fld3,companynr from t2 where companynr = 58 order by fld3;
 
62
fld3    companynr
 
63
concoct 58
 
64
druggists       58
 
65
engrossing      58
 
66
Eurydice        58
 
67
exclaimers      58
 
68
ferociousness   58
 
69
hopelessness    58
 
70
Huey    58
 
71
imaginable      58
 
72
judges  58
 
73
merging 58
 
74
ostrich 58
 
75
peering 58
 
76
Phelps  58
 
77
presumes        58
 
78
Ruth    58
 
79
sentences       58
 
80
Shylock 58
 
81
straggled       58
 
82
synergy 58
 
83
thanking        58
 
84
tying   58
 
85
unlocks 58
 
86
select fld3 from t2 order by fld3 desc limit 10;
 
87
fld3
 
88
youthfulness
 
89
yelped
 
90
Wotan
 
91
workers
 
92
Witt
 
93
witchcraft
 
94
Winsett
 
95
Willy
 
96
willed
 
97
wildcats
 
98
select fld3 from t2 order by fld3 desc limit 5;
 
99
fld3
 
100
youthfulness
 
101
yelped
 
102
Wotan
 
103
workers
 
104
Witt
 
105
select fld3 from t2 order by fld3 desc limit 5,5;
 
106
fld3
 
107
witchcraft
 
108
Winsett
 
109
Willy
 
110
willed
 
111
wildcats
 
112
select t2.fld3 from t2 where fld3 = 'honeysuckle';
 
113
fld3
 
114
honeysuckle
 
115
select t2.fld3 from t2 where fld3 LIKE 'honeysuckl_';
 
116
fld3
 
117
honeysuckle
 
118
select t2.fld3 from t2 where fld3 LIKE 'hon_ysuckl_';
 
119
fld3
 
120
honeysuckle
 
121
select t2.fld3 from t2 where fld3 LIKE 'honeysuckle%';
 
122
fld3
 
123
honeysuckle
 
124
select t2.fld3 from t2 where fld3 LIKE 'h%le';
 
125
fld3
 
126
honeysuckle
 
127
select t2.fld3 from t2 where fld3 LIKE 'honeysuckle_';
 
128
fld3
 
129
select t2.fld3 from t2 where fld3 LIKE 'don_t_find_me_please%';
 
130
fld3
 
131
explain select t2.fld3 from t2 where fld3 = 'honeysuckle';
 
132
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
133
1       SIMPLE  t2      ref     fld3    fld3    30      const   1       Using where; Using index
 
134
explain select fld3 from t2 ignore index (fld3) where fld3 = 'honeysuckle';
 
135
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
136
1       SIMPLE  t2      ALL     NULL    NULL    NULL    NULL    1199    Using where
 
137
explain select fld3 from t2 use index (fld1) where fld3 = 'honeysuckle';
 
138
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
139
1       SIMPLE  t2      ALL     NULL    NULL    NULL    NULL    1199    Using where
 
140
explain select fld3 from t2 use index (fld3) where fld3 = 'honeysuckle';
 
141
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
142
1       SIMPLE  t2      ref     fld3    fld3    30      const   1       Using where; Using index
 
143
explain select fld3 from t2 use index (fld1,fld3) where fld3 = 'honeysuckle';
 
144
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
145
1       SIMPLE  t2      ref     fld3    fld3    30      const   1       Using where; Using index
 
146
explain select fld3 from t2 ignore index (fld3,not_used);
 
147
ERROR 42000: Key 'not_used' doesn't exist in table 't2'
 
148
explain select fld3 from t2 use index (not_used);
 
149
ERROR 42000: Key 'not_used' doesn't exist in table 't2'
 
150
select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3;
 
151
fld3
 
152
honeysuckle
 
153
honoring
 
154
explain select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3;
 
155
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
156
1       SIMPLE  t2      range   fld3    fld3    30      NULL    2       Using where; Using index
 
157
select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3;
 
158
fld1    fld3
 
159
148504  Colombo
 
160
068305  Colombo
 
161
000000  nondecreasing
 
162
select fld1,fld3 from t2 where companynr = 37 and fld3 = 'appendixes';
 
163
fld1    fld3
 
164
232605  appendixes
 
165
1232605 appendixes
 
166
1232606 appendixes
 
167
1232607 appendixes
 
168
1232608 appendixes
 
169
1232609 appendixes
 
170
select fld1 from t2 where fld1=250501 or fld1="250502";
 
171
fld1
 
172
250501
 
173
250502
 
174
explain select fld1 from t2 where fld1=250501 or fld1="250502";
 
175
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
176
1       SIMPLE  t2      range   fld1    fld1    4       NULL    2       Using where; Using index
 
177
select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502;
 
178
fld1
 
179
250501
 
180
250502
 
181
250505
 
182
250601
 
183
explain select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502;
 
184
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
185
1       SIMPLE  t2      range   fld1    fld1    4       NULL    4       Using where; Using index
 
186
select fld1,fld3 from t2 where companynr = 37 and fld3 like 'f%';
 
187
fld1    fld3
 
188
218401  faithful
 
189
018007  fanatic
 
190
228311  fated
 
191
018017  featherweight
 
192
218022  feed
 
193
088303  feminine
 
194
058004  Fenton
 
195
038017  fetched
 
196
018054  fetters
 
197
208101  fiftieth
 
198
238007  filial
 
199
013606  fingerings
 
200
218008  finishers
 
201
038205  firearm
 
202
188505  fitting
 
203
202301  Fitzpatrick
 
204
238008  fixedly
 
205
012001  flanking
 
206
018103  flint
 
207
018104  flopping
 
208
188007  flurried
 
209
013602  foldout
 
210
226205  foothill
 
211
232102  forgivably
 
212
228306  forthcoming
 
213
186002  freakish
 
214
208113  freest
 
215
231315  freezes
 
216
036002  funereal
 
217
226209  furnishings
 
218
198006  furthermore
 
219
select fld3 from t2 where fld3 like "L%" and fld3 = "ok";
 
220
fld3
 
221
select fld3 from t2 where (fld3 like "C%" and fld3 = "Chantilly");
 
222
fld3
 
223
Chantilly
 
224
select fld1,fld3 from t2 where fld1 like "25050%";
 
225
fld1    fld3
 
226
250501  poisoning
 
227
250502  Iraqis
 
228
250503  heaving
 
229
250504  population
 
230
250505  bomb
 
231
select fld1,fld3 from t2 where fld1 like "25050_";
 
232
fld1    fld3
 
233
250501  poisoning
 
234
250502  Iraqis
 
235
250503  heaving
 
236
250504  population
 
237
250505  bomb
 
238
select distinct companynr from t2;
 
239
companynr
 
240
00
 
241
37
 
242
36
 
243
50
 
244
58
 
245
29
 
246
40
 
247
53
 
248
65
 
249
41
 
250
34
 
251
68
 
252
select distinct companynr from t2 order by companynr;
 
253
companynr
 
254
00
 
255
29
 
256
34
 
257
36
 
258
37
 
259
40
 
260
41
 
261
50
 
262
53
 
263
58
 
264
65
 
265
68
 
266
select distinct companynr from t2 order by companynr desc;
 
267
companynr
 
268
68
 
269
65
 
270
58
 
271
53
 
272
50
 
273
41
 
274
40
 
275
37
 
276
36
 
277
34
 
278
29
 
279
00
 
280
select distinct t2.fld3,period from t2,t1 where companynr=37 and fld3 like "O%";
 
281
fld3    period
 
282
obliterates     9410
 
283
offload 9410
 
284
opaquely        9410
 
285
organizer       9410
 
286
overestimating  9410
 
287
overlay 9410
 
288
select distinct fld3 from t2 where companynr = 34 order by fld3;
 
289
fld3
 
290
absentee
 
291
accessed
 
292
ahead
 
293
alphabetic
 
294
Asiaticizations
 
295
attitude
 
296
aye
 
297
bankruptcies
 
298
belays
 
299
Blythe
 
300
bomb
 
301
boulevard
 
302
bulldozes
 
303
cannot
 
304
caressing
 
305
charcoal
 
306
checksumming
 
307
chess
 
308
clubroom
 
309
colorful
 
310
cosy
 
311
creator
 
312
crying
 
313
Darius
 
314
diffusing
 
315
duality
 
316
Eiffel
 
317
Epiphany
 
318
Ernestine
 
319
explorers
 
320
exterminated
 
321
famine
 
322
forked
 
323
Gershwins
 
324
heaving
 
325
Hodges
 
326
Iraqis
 
327
Italianization
 
328
Lagos
 
329
landslide
 
330
libretto
 
331
Majorca
 
332
mastering
 
333
narrowed
 
334
occurred
 
335
offerers
 
336
Palestine
 
337
Peruvianizes
 
338
pharmaceutic
 
339
poisoning
 
340
population
 
341
Pygmalion
 
342
rats
 
343
realest
 
344
recording
 
345
regimented
 
346
retransmitting
 
347
reviver
 
348
rouses
 
349
scars
 
350
sicker
 
351
sleepwalk
 
352
stopped
 
353
sugars
 
354
translatable
 
355
uncles
 
356
unexpected
 
357
uprisings
 
358
versatility
 
359
vest
 
360
select distinct fld3 from t2 limit 10;
 
361
fld3
 
362
abates
 
363
abiding
 
364
Abraham
 
365
abrogating
 
366
absentee
 
367
abut
 
368
accessed
 
369
accruing
 
370
accumulating
 
371
accuracies
 
372
select distinct fld3 from t2 having fld3 like "A%" limit 10;
 
373
fld3
 
374
abates
 
375
abiding
 
376
Abraham
 
377
abrogating
 
378
absentee
 
379
abut
 
380
accessed
 
381
accruing
 
382
accumulating
 
383
accuracies
 
384
select distinct substring(fld3,1,3) from t2 where fld3 like "A%";
 
385
substring(fld3,1,3)
 
386
aba
 
387
abi
 
388
Abr
 
389
abs
 
390
abu
 
391
acc
 
392
acq
 
393
acu
 
394
Ade
 
395
adj
 
396
Adl
 
397
adm
 
398
Ado
 
399
ads
 
400
adv
 
401
aer
 
402
aff
 
403
afi
 
404
afl
 
405
afo
 
406
agi
 
407
ahe
 
408
aim
 
409
air
 
410
Ald
 
411
alg
 
412
ali
 
413
all
 
414
alp
 
415
alr
 
416
ama
 
417
ame
 
418
amm
 
419
ana
 
420
and
 
421
ane
 
422
Ang
 
423
ani
 
424
Ann
 
425
Ant
 
426
api
 
427
app
 
428
aqu
 
429
Ara
 
430
arc
 
431
Arm
 
432
arr
 
433
Art
 
434
Asi
 
435
ask
 
436
asp
 
437
ass
 
438
ast
 
439
att
 
440
aud
 
441
Aug
 
442
aut
 
443
ave
 
444
avo
 
445
awe
 
446
aye
 
447
Azt
 
448
select distinct substring(fld3,1,3) as a from t2 having a like "A%" order by a limit 10;
 
449
a
 
450
aba
 
451
abi
 
452
Abr
 
453
abs
 
454
abu
 
455
acc
 
456
acq
 
457
acu
 
458
Ade
 
459
adj
 
460
select distinct substring(fld3,1,3) from t2 where fld3 like "A%" limit 10;
 
461
substring(fld3,1,3)
 
462
aba
 
463
abi
 
464
Abr
 
465
abs
 
466
abu
 
467
acc
 
468
acq
 
469
acu
 
470
Ade
 
471
adj
 
472
select distinct substring(fld3,1,3) as a from t2 having a like "A%" limit 10;
 
473
a
 
474
aba
 
475
abi
 
476
Abr
 
477
abs
 
478
abu
 
479
acc
 
480
acq
 
481
acu
 
482
Ade
 
483
adj
 
484
create table t3 (
 
485
period    int not null,
 
486
name      char(32) not null,
 
487
companynr int not null,
 
488
price     double(11,0),
 
489
price2     double(11,0),
 
490
key (period),
 
491
key (name)
 
492
);
 
493
create temporary table tmp engine = myisam select * from t3;
 
494
insert into t3 select * from tmp;
 
495
insert into tmp select * from t3;
 
496
insert into t3 select * from tmp;
 
497
insert into tmp select * from t3;
 
498
insert into t3 select * from tmp;
 
499
insert into tmp select * from t3;
 
500
insert into t3 select * from tmp;
 
501
insert into tmp select * from t3;
 
502
insert into t3 select * from tmp;
 
503
insert into tmp select * from t3;
 
504
insert into t3 select * from tmp;
 
505
insert into tmp select * from t3;
 
506
insert into t3 select * from tmp;
 
507
insert into tmp select * from t3;
 
508
insert into t3 select * from tmp;
 
509
insert into tmp select * from t3;
 
510
insert into t3 select * from tmp;
 
511
alter table t3 add t2nr int not null auto_increment primary key first;
 
512
drop table tmp;
 
513
SET SQL_BIG_TABLES=1;
 
514
select distinct concat(fld3," ",fld3) as namn from t2,t3 where t2.fld1=t3.t2nr order by namn limit 10;
 
515
namn
 
516
Abraham Abraham
 
517
abrogating abrogating
 
518
admonishing admonishing
 
519
Adolph Adolph
 
520
afield afield
 
521
aging aging
 
522
ammonium ammonium
 
523
analyzable analyzable
 
524
animals animals
 
525
animized animized
 
526
SET SQL_BIG_TABLES=0;
 
527
select distinct concat(fld3," ",fld3) from t2,t3 where t2.fld1=t3.t2nr order by fld3 limit 10;
 
528
concat(fld3," ",fld3)
 
529
Abraham Abraham
 
530
abrogating abrogating
 
531
admonishing admonishing
 
532
Adolph Adolph
 
533
afield afield
 
534
aging aging
 
535
ammonium ammonium
 
536
analyzable analyzable
 
537
animals animals
 
538
animized animized
 
539
select distinct fld5 from t2 limit 10;
 
540
fld5
 
541
neat
 
542
Steinberg
 
543
jarring
 
544
tinily
 
545
balled
 
546
persist
 
547
attainments
 
548
fanatic
 
549
measures
 
550
rightfulness
 
551
select distinct fld3,count(*) from t2 group by companynr,fld3 limit 10;
 
552
fld3    count(*)
 
553
affixed 1
 
554
and     1
 
555
annoyers        1
 
556
Anthony 1
 
557
assayed 1
 
558
assurers        1
 
559
attendants      1
 
560
bedlam  1
 
561
bedpost 1
 
562
boasted 1
 
563
SET SQL_BIG_TABLES=1;
 
564
select distinct fld3,count(*) from t2 group by companynr,fld3 limit 10;
 
565
fld3    count(*)
 
566
affixed 1
 
567
and     1
 
568
annoyers        1
 
569
Anthony 1
 
570
assayed 1
 
571
assurers        1
 
572
attendants      1
 
573
bedlam  1
 
574
bedpost 1
 
575
boasted 1
 
576
SET SQL_BIG_TABLES=0;
 
577
select distinct fld3,repeat("a",length(fld3)),count(*) from t2 group by companynr,fld3 limit 100,10;
 
578
fld3    repeat("a",length(fld3))        count(*)
 
579
circus  aaaaaa  1
 
580
cited   aaaaa   1
 
581
Colombo aaaaaaa 1
 
582
congresswoman   aaaaaaaaaaaaa   1
 
583
contrition      aaaaaaaaaa      1
 
584
corny   aaaaa   1
 
585
cultivation     aaaaaaaaaaa     1
 
586
definiteness    aaaaaaaaaaaa    1
 
587
demultiplex     aaaaaaaaaaa     1
 
588
disappointing   aaaaaaaaaaaaa   1
 
589
select distinct companynr,rtrim(space(512+companynr)) from t3 order by 1,2;
 
590
companynr       rtrim(space(512+companynr))
 
591
37      
 
592
78      
 
593
101     
 
594
154     
 
595
311     
 
596
447     
 
597
512     
 
598
select distinct fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by fld3;
 
599
fld3
 
600
explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by t3.t2nr,fld3;
 
601
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
602
1       SIMPLE  t2      ALL     fld1    NULL    NULL    NULL    1199    Using where; Using temporary; Using filesort
 
603
1       SIMPLE  t3      eq_ref  PRIMARY PRIMARY 4       test.t2.fld1    1       Using where; Using index
 
604
explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period;
 
605
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
606
1       SIMPLE  t1      ALL     period  NULL    NULL    NULL    41810   Using temporary; Using filesort
 
607
1       SIMPLE  t3      ref     period  period  4       test.t1.period  4181    
 
608
explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10;
 
609
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
610
1       SIMPLE  t3      index   period  period  4       NULL    1       
 
611
1       SIMPLE  t1      ref     period  period  4       test.t3.period  4181    
 
612
explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10;
 
613
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
614
1       SIMPLE  t1      index   period  period  4       NULL    1       
 
615
1       SIMPLE  t3      ref     period  period  4       test.t1.period  4181    
 
616
select period from t1;
 
617
period
 
618
9410
 
619
select period from t1 where period=1900;
 
620
period
 
621
select fld3,period from t1,t2 where fld1 = 011401 order by period;
 
622
fld3    period
 
623
breaking        9410
 
624
select fld3,period from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period=1001;
 
625
fld3    period
 
626
breaking        1001
 
627
explain select fld3,period from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period;
 
628
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
629
1       SIMPLE  t2      const   fld1    fld1    4       const   1       
 
630
1       SIMPLE  t3      const   PRIMARY,period  PRIMARY 4       const   1       
 
631
select fld3,period from t2,t1 where companynr*10 = 37*10;
 
632
fld3    period
 
633
breaking        9410
 
634
Romans  9410
 
635
intercepted     9410
 
636
bewilderingly   9410
 
637
astound 9410
 
638
admonishing     9410
 
639
sumac   9410
 
640
flanking        9410
 
641
combed  9410
 
642
subjective      9410
 
643
scatterbrain    9410
 
644
Eulerian        9410
 
645
Kane    9410
 
646
overlay 9410
 
647
perturb 9410
 
648
goblins 9410
 
649
annihilates     9410
 
650
Wotan   9410
 
651
snatching       9410
 
652
concludes       9410
 
653
laterally       9410
 
654
yelped  9410
 
655
grazing 9410
 
656
Baird   9410
 
657
celery  9410
 
658
misunderstander 9410
 
659
handgun 9410
 
660
foldout 9410
 
661
mystic  9410
 
662
succumbed       9410
 
663
Nabisco 9410
 
664
fingerings      9410
 
665
aging   9410
 
666
afield  9410
 
667
ammonium        9410
 
668
boat    9410
 
669
intelligibility 9410
 
670
Augustine       9410
 
671
teethe  9410
 
672
dreaded 9410
 
673
scholastics     9410
 
674
audiology       9410
 
675
wallet  9410
 
676
parters 9410
 
677
eschew  9410
 
678
quitter 9410
 
679
neat    9410
 
680
Steinberg       9410
 
681
jarring 9410
 
682
tinily  9410
 
683
balled  9410
 
684
persist 9410
 
685
attainments     9410
 
686
fanatic 9410
 
687
measures        9410
 
688
rightfulness    9410
 
689
capably 9410
 
690
impulsive       9410
 
691
starlet 9410
 
692
terminators     9410
 
693
untying 9410
 
694
announces       9410
 
695
featherweight   9410
 
696
pessimist       9410
 
697
daughter        9410
 
698
decliner        9410
 
699
lawgiver        9410
 
700
stated  9410
 
701
readable        9410
 
702
attrition       9410
 
703
cascade 9410
 
704
motors  9410
 
705
interrogate     9410
 
706
pests   9410
 
707
stairway        9410
 
708
dopers  9410
 
709
testicle        9410
 
710
Parsifal        9410
 
711
leavings        9410
 
712
postulation     9410
 
713
squeaking       9410
 
714
contrasted      9410
 
715
leftover        9410
 
716
whiteners       9410
 
717
erases  9410
 
718
Punjab  9410
 
719
Merritt 9410
 
720
Quixotism       9410
 
721
sweetish        9410
 
722
dogging 9410
 
723
scornfully      9410
 
724
bellow  9410
 
725
bills   9410
 
726
cupboard        9410
 
727
sureties        9410
 
728
puddings        9410
 
729
fetters 9410
 
730
bivalves        9410
 
731
incurring       9410
 
732
Adolph  9410
 
733
pithed  9410
 
734
Miles   9410
 
735
trimmings       9410
 
736
tragedies       9410
 
737
skulking        9410
 
738
flint   9410
 
739
flopping        9410
 
740
relaxing        9410
 
741
offload 9410
 
742
suites  9410
 
743
lists   9410
 
744
animized        9410
 
745
multilayer      9410
 
746
standardizes    9410
 
747
Judas   9410
 
748
vacuuming       9410
 
749
dentally        9410
 
750
humanness       9410
 
751
inch    9410
 
752
Weissmuller     9410
 
753
irresponsibly   9410
 
754
luckily 9410
 
755
culled  9410
 
756
medical 9410
 
757
bloodbath       9410
 
758
subschema       9410
 
759
animals 9410
 
760
Micronesia      9410
 
761
repetitions     9410
 
762
Antares 9410
 
763
ventilate       9410
 
764
pityingly       9410
 
765
interdependent  9410
 
766
Graves  9410
 
767
neonatal        9410
 
768
chafe   9410
 
769
honoring        9410
 
770
realtor 9410
 
771
elite   9410
 
772
funereal        9410
 
773
abrogating      9410
 
774
sorters 9410
 
775
Conley  9410
 
776
lectured        9410
 
777
Abraham 9410
 
778
Hawaii  9410
 
779
cage    9410
 
780
hushes  9410
 
781
Simla   9410
 
782
reporters       9410
 
783
Dutchman        9410
 
784
descendants     9410
 
785
groupings       9410
 
786
dissociate      9410
 
787
coexist 9410
 
788
Beebe   9410
 
789
Taoism  9410
 
790
Connally        9410
 
791
fetched 9410
 
792
checkpoints     9410
 
793
rusting 9410
 
794
galling 9410
 
795
obliterates     9410
 
796
traitor 9410
 
797
resumes 9410
 
798
analyzable      9410
 
799
terminator      9410
 
800
gritty  9410
 
801
firearm 9410
 
802
minima  9410
 
803
Selfridge       9410
 
804
disable 9410
 
805
witchcraft      9410
 
806
betroth 9410
 
807
Manhattanize    9410
 
808
imprint 9410
 
809
peeked  9410
 
810
swelling        9410
 
811
interrelationships      9410
 
812
riser   9410
 
813
Gandhian        9410
 
814
peacock 9410
 
815
bee     9410
 
816
kanji   9410
 
817
dental  9410
 
818
scarf   9410
 
819
chasm   9410
 
820
insolence       9410
 
821
syndicate       9410
 
822
alike   9410
 
823
imperial        9410
 
824
convulsion      9410
 
825
railway 9410
 
826
validate        9410
 
827
normalizes      9410
 
828
comprehensive   9410
 
829
chewing 9410
 
830
denizen 9410
 
831
schemer 9410
 
832
chronicle       9410
 
833
Kline   9410
 
834
Anatole 9410
 
835
partridges      9410
 
836
brunch  9410
 
837
recruited       9410
 
838
dimensions      9410
 
839
Chicana 9410
 
840
announced       9410
 
841
praised 9410
 
842
employing       9410
 
843
linear  9410
 
844
quagmire        9410
 
845
western 9410
 
846
relishing       9410
 
847
serving 9410
 
848
scheduling      9410
 
849
lore    9410
 
850
eventful        9410
 
851
arteriole       9410
 
852
disentangle     9410
 
853
cured   9410
 
854
Fenton  9410
 
855
avoidable       9410
 
856
drains  9410
 
857
detectably      9410
 
858
husky   9410
 
859
impelling       9410
 
860
undoes  9410
 
861
evened  9410
 
862
squeezes        9410
 
863
destroyer       9410
 
864
rudeness        9410
 
865
beaner  9410
 
866
boorish 9410
 
867
Everhart        9410
 
868
encompass       9410
 
869
mushrooms       9410
 
870
Alison  9410
 
871
externally      9410
 
872
pellagra        9410
 
873
cult    9410
 
874
creek   9410
 
875
Huffman 9410
 
876
Majorca 9410
 
877
governing       9410
 
878
gadfly  9410
 
879
reassigned      9410
 
880
intentness      9410
 
881
craziness       9410
 
882
psychic 9410
 
883
squabbled       9410
 
884
burlesque       9410
 
885
capped  9410
 
886
extracted       9410
 
887
DiMaggio        9410
 
888
exclamation     9410
 
889
subdirectory    9410
 
890
Gothicism       9410
 
891
feminine        9410
 
892
metaphysically  9410
 
893
sanding 9410
 
894
Miltonism       9410
 
895
freakish        9410
 
896
index   9410
 
897
straight        9410
 
898
flurried        9410
 
899
denotative      9410
 
900
coming  9410
 
901
commencements   9410
 
902
gentleman       9410
 
903
gifted  9410
 
904
Shanghais       9410
 
905
sportswriting   9410
 
906
sloping 9410
 
907
navies  9410
 
908
leaflet 9410
 
909
shooter 9410
 
910
Joplin  9410
 
911
babies  9410
 
912
assails 9410
 
913
admiring        9410
 
914
swaying 9410
 
915
Goldstine       9410
 
916
fitting 9410
 
917
Norwalk 9410
 
918
analogy 9410
 
919
deludes 9410
 
920
cokes   9410
 
921
Clayton 9410
 
922
exhausts        9410
 
923
causality       9410
 
924
sating  9410
 
925
icon    9410
 
926
throttles       9410
 
927
communicants    9410
 
928
dehydrate       9410
 
929
priceless       9410
 
930
publicly        9410
 
931
incidentals     9410
 
932
commonplace     9410
 
933
mumbles 9410
 
934
furthermore     9410
 
935
cautioned       9410
 
936
parametrized    9410
 
937
registration    9410
 
938
sadly   9410
 
939
positioning     9410
 
940
babysitting     9410
 
941
eternal 9410
 
942
hoarder 9410
 
943
congregates     9410
 
944
rains   9410
 
945
workers 9410
 
946
sags    9410
 
947
unplug  9410
 
948
garage  9410
 
949
boulder 9410
 
950
specifics       9410
 
951
Teresa  9410
 
952
Winsett 9410
 
953
convenient      9410
 
954
buckboards      9410
 
955
amenities       9410
 
956
resplendent     9410
 
957
sews    9410
 
958
participated    9410
 
959
Simon   9410
 
960
certificates    9410
 
961
Fitzpatrick     9410
 
962
Evanston        9410
 
963
misted  9410
 
964
textures        9410
 
965
save    9410
 
966
count   9410
 
967
rightful        9410
 
968
chaperone       9410
 
969
Lizzy   9410
 
970
clenched        9410
 
971
effortlessly    9410
 
972
accessed        9410
 
973
beaters 9410
 
974
Hornblower      9410
 
975
vests   9410
 
976
indulgences     9410
 
977
infallibly      9410
 
978
unwilling       9410
 
979
excrete 9410
 
980
spools  9410
 
981
crunches        9410
 
982
overestimating  9410
 
983
ineffective     9410
 
984
humiliation     9410
 
985
sophomore       9410
 
986
star    9410
 
987
rifles  9410
 
988
dialysis        9410
 
989
arriving        9410
 
990
indulge 9410
 
991
clockers        9410
 
992
languages       9410
 
993
Antarctica      9410
 
994
percentage      9410
 
995
ceiling 9410
 
996
specification   9410
 
997
regimented      9410
 
998
ciphers 9410
 
999
pictures        9410
 
1000
serpents        9410
 
1001
allot   9410
 
1002
realized        9410
 
1003
mayoral 9410
 
1004
opaquely        9410
 
1005
hostess 9410
 
1006
fiftieth        9410
 
1007
incorrectly     9410
 
1008
decomposition   9410
 
1009
stranglings     9410
 
1010
mixture 9410
 
1011
electroencephalography  9410
 
1012
similarities    9410
 
1013
charges 9410
 
1014
freest  9410
 
1015
Greenberg       9410
 
1016
tinting 9410
 
1017
expelled        9410
 
1018
warm    9410
 
1019
smoothed        9410
 
1020
deductions      9410
 
1021
Romano  9410
 
1022
bitterroot      9410
 
1023
corset  9410
 
1024
securing        9410
 
1025
environing      9410
 
1026
cute    9410
 
1027
Crays   9410
 
1028
heiress 9410
 
1029
inform  9410
 
1030
avenge  9410
 
1031
universals      9410
 
1032
Kinsey  9410
 
1033
ravines 9410
 
1034
bestseller      9410
 
1035
equilibrium     9410
 
1036
extents 9410
 
1037
relatively      9410
 
1038
pressure        9410
 
1039
critiques       9410
 
1040
befouled        9410
 
1041
rightfully      9410
 
1042
mechanizing     9410
 
1043
Latinizes       9410
 
1044
timesharing     9410
 
1045
Aden    9410
 
1046
embassies       9410
 
1047
males   9410
 
1048
shapelessly     9410
 
1049
mastering       9410
 
1050
Newtonian       9410
 
1051
finishers       9410
 
1052
abates  9410
 
1053
teem    9410
 
1054
kiting  9410
 
1055
stodgy  9410
 
1056
feed    9410
 
1057
guitars 9410
 
1058
airships        9410
 
1059
store   9410
 
1060
denounces       9410
 
1061
Pyle    9410
 
1062
Saxony  9410
 
1063
serializations  9410
 
1064
Peruvian        9410
 
1065
taxonomically   9410
 
1066
kingdom 9410
 
1067
stint   9410
 
1068
Sault   9410
 
1069
faithful        9410
 
1070
Ganymede        9410
 
1071
tidiness        9410
 
1072
gainful 9410
 
1073
contrary        9410
 
1074
Tipperary       9410
 
1075
tropics 9410
 
1076
theorizers      9410
 
1077
renew   9410
 
1078
already 9410
 
1079
terminal        9410
 
1080
Hegelian        9410
 
1081
hypothesizer    9410
 
1082
warningly       9410
 
1083
journalizing    9410
 
1084
nested  9410
 
1085
Lars    9410
 
1086
saplings        9410
 
1087
foothill        9410
 
1088
labeled 9410
 
1089
imperiously     9410
 
1090
reporters       9410
 
1091
furnishings     9410
 
1092
precipitable    9410
 
1093
discounts       9410
 
1094
excises 9410
 
1095
Stalin  9410
 
1096
despot  9410
 
1097
ripeness        9410
 
1098
Arabia  9410
 
1099
unruly  9410
 
1100
mournfulness    9410
 
1101
boom    9410
 
1102
slaughter       9410
 
1103
Sabine  9410
 
1104
handy   9410
 
1105
rural   9410
 
1106
organizer       9410
 
1107
shipyard        9410
 
1108
civics  9410
 
1109
inaccuracy      9410
 
1110
rules   9410
 
1111
juveniles       9410
 
1112
comprised       9410
 
1113
investigations  9410
 
1114
stabilizes      9410
 
1115
seminaries      9410
 
1116
Hunter  9410
 
1117
sporty  9410
 
1118
test    9410
 
1119
weasels 9410
 
1120
CERN    9410
 
1121
tempering       9410
 
1122
afore   9410
 
1123
Galatean        9410
 
1124
techniques      9410
 
1125
error   9410
 
1126
veranda 9410
 
1127
severely        9410
 
1128
Cassites        9410
 
1129
forthcoming     9410
 
1130
guides  9410
 
1131
vanish  9410
 
1132
lied    9410
 
1133
sawtooth        9410
 
1134
fated   9410
 
1135
gradually       9410
 
1136
widens  9410
 
1137
preclude        9410
 
1138
evenhandedly    9410
 
1139
percentage      9410
 
1140
disobedience    9410
 
1141
humility        9410
 
1142
gleaning        9410
 
1143
petted  9410
 
1144
bloater 9410
 
1145
minion  9410
 
1146
marginal        9410
 
1147
apiary  9410
 
1148
measures        9410
 
1149
precaution      9410
 
1150
repelled        9410
 
1151
primary 9410
 
1152
coverings       9410
 
1153
Artemia 9410
 
1154
navigate        9410
 
1155
spatial 9410
 
1156
Gurkha  9410
 
1157
meanwhile       9410
 
1158
Melinda 9410
 
1159
Butterfield     9410
 
1160
Aldrich 9410
 
1161
previewing      9410
 
1162
glut    9410
 
1163
unaffected      9410
 
1164
inmate  9410
 
1165
mineral 9410
 
1166
impending       9410
 
1167
meditation      9410
 
1168
ideas   9410
 
1169
miniaturizes    9410
 
1170
lewdly  9410
 
1171
title   9410
 
1172
youthfulness    9410
 
1173
creak   9410
 
1174
Chippewa        9410
 
1175
clamored        9410
 
1176
freezes 9410
 
1177
forgivably      9410
 
1178
reduce  9410
 
1179
McGovern        9410
 
1180
Nazis   9410
 
1181
epistle 9410
 
1182
socializes      9410
 
1183
conceptions     9410
 
1184
Kevin   9410
 
1185
uncovering      9410
 
1186
chews   9410
 
1187
appendixes      9410
 
1188
appendixes      9410
 
1189
appendixes      9410
 
1190
appendixes      9410
 
1191
appendixes      9410
 
1192
appendixes      9410
 
1193
raining 9410
 
1194
infest  9410
 
1195
compartment     9410
 
1196
minting 9410
 
1197
ducks   9410
 
1198
roped   9410
 
1199
waltz   9410
 
1200
Lillian 9410
 
1201
repressions     9410
 
1202
chillingly      9410
 
1203
noncritical     9410
 
1204
lithograph      9410
 
1205
spongers        9410
 
1206
parenthood      9410
 
1207
posed   9410
 
1208
instruments     9410
 
1209
filial  9410
 
1210
fixedly 9410
 
1211
relives 9410
 
1212
Pandora 9410
 
1213
watering        9410
 
1214
ungrateful      9410
 
1215
secures 9410
 
1216
poison  9410
 
1217
dusted  9410
 
1218
encompasses     9410
 
1219
presentation    9410
 
1220
Kantian 9410
 
1221
select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price;
 
1222
fld3    period  price   price2
 
1223
admonishing     1002    28357832        8723648
 
1224
analyzable      1002    28357832        8723648
 
1225
annihilates     1001    5987435 234724
 
1226
Antares 1002    28357832        8723648
 
1227
astound 1001    5987435 234724
 
1228
audiology       1001    5987435 234724
 
1229
Augustine       1002    28357832        8723648
 
1230
Baird   1002    28357832        8723648
 
1231
bewilderingly   1001    5987435 234724
 
1232
breaking        1001    5987435 234724
 
1233
Conley  1001    5987435 234724
 
1234
dentally        1002    28357832        8723648
 
1235
dissociate      1002    28357832        8723648
 
1236
elite   1001    5987435 234724
 
1237
eschew  1001    5987435 234724
 
1238
Eulerian        1001    5987435 234724
 
1239
flanking        1001    5987435 234724
 
1240
foldout 1002    28357832        8723648
 
1241
funereal        1002    28357832        8723648
 
1242
galling 1002    28357832        8723648
 
1243
Graves  1001    5987435 234724
 
1244
grazing 1001    5987435 234724
 
1245
groupings       1001    5987435 234724
 
1246
handgun 1001    5987435 234724
 
1247
humility        1002    28357832        8723648
 
1248
impulsive       1002    28357832        8723648
 
1249
inch    1001    5987435 234724
 
1250
intelligibility 1001    5987435 234724
 
1251
jarring 1001    5987435 234724
 
1252
lawgiver        1001    5987435 234724
 
1253
lectured        1002    28357832        8723648
 
1254
Merritt 1002    28357832        8723648
 
1255
neonatal        1001    5987435 234724
 
1256
offload 1002    28357832        8723648
 
1257
parters 1002    28357832        8723648
 
1258
pityingly       1002    28357832        8723648
 
1259
puddings        1002    28357832        8723648
 
1260
Punjab  1001    5987435 234724
 
1261
quitter 1002    28357832        8723648
 
1262
realtor 1001    5987435 234724
 
1263
relaxing        1001    5987435 234724
 
1264
repetitions     1001    5987435 234724
 
1265
resumes 1001    5987435 234724
 
1266
Romans  1002    28357832        8723648
 
1267
rusting 1001    5987435 234724
 
1268
scholastics     1001    5987435 234724
 
1269
skulking        1002    28357832        8723648
 
1270
stated  1002    28357832        8723648
 
1271
suites  1002    28357832        8723648
 
1272
sureties        1001    5987435 234724
 
1273
testicle        1002    28357832        8723648
 
1274
tinily  1002    28357832        8723648
 
1275
tragedies       1001    5987435 234724
 
1276
trimmings       1001    5987435 234724
 
1277
vacuuming       1001    5987435 234724
 
1278
ventilate       1001    5987435 234724
 
1279
wallet  1001    5987435 234724
 
1280
Weissmuller     1002    28357832        8723648
 
1281
Wotan   1002    28357832        8723648
 
1282
select t2.fld1,fld3,period,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period = 1001 and t2.companynr = 37;
 
1283
fld1    fld3    period  price   price2
 
1284
018201  relaxing        1001    5987435 234724
 
1285
018601  vacuuming       1001    5987435 234724
 
1286
018801  inch    1001    5987435 234724
 
1287
018811  repetitions     1001    5987435 234724
 
1288
create table t4 (
 
1289
companynr tinyint(2) unsigned zerofill NOT NULL default '00',
 
1290
companyname char(30) NOT NULL default '',
 
1291
PRIMARY KEY (companynr),
 
1292
UNIQUE KEY companyname(companyname)
 
1293
) ENGINE=MyISAM MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames';
 
1294
select STRAIGHT_JOIN t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr;
 
1295
companynr       companyname
 
1296
00      Unknown
 
1297
29      company 1
 
1298
34      company 2
 
1299
36      company 3
 
1300
37      company 4
 
1301
40      company 5
 
1302
41      company 6
 
1303
50      company 11
 
1304
53      company 7
 
1305
58      company 8
 
1306
65      company 9
 
1307
68      company 10
 
1308
select SQL_SMALL_RESULT t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr;
 
1309
companynr       companyname
 
1310
00      Unknown
 
1311
29      company 1
 
1312
34      company 2
 
1313
36      company 3
 
1314
37      company 4
 
1315
40      company 5
 
1316
41      company 6
 
1317
50      company 11
 
1318
53      company 7
 
1319
58      company 8
 
1320
65      company 9
 
1321
68      company 10
 
1322
select * from t1,t1 t12;
 
1323
Period  Varor_period    Period  Varor_period
 
1324
9410    9412    9410    9412
 
1325
select t2.fld1,t22.fld1 from t2,t2 t22 where t2.fld1 >= 250501 and t2.fld1 <= 250505 and t22.fld1 >= 250501 and t22.fld1 <= 250505;
 
1326
fld1    fld1
 
1327
250501  250501
 
1328
250502  250501
 
1329
250503  250501
 
1330
250504  250501
 
1331
250505  250501
 
1332
250501  250502
 
1333
250502  250502
 
1334
250503  250502
 
1335
250504  250502
 
1336
250505  250502
 
1337
250501  250503
 
1338
250502  250503
 
1339
250503  250503
 
1340
250504  250503
 
1341
250505  250503
 
1342
250501  250504
 
1343
250502  250504
 
1344
250503  250504
 
1345
250504  250504
 
1346
250505  250504
 
1347
250501  250505
 
1348
250502  250505
 
1349
250503  250505
 
1350
250504  250505
 
1351
250505  250505
 
1352
insert into t2 (fld1, companynr) values (999999,99);
 
1353
select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null;
 
1354
companynr       companyname
 
1355
99      NULL
 
1356
select count(*) from t2 left join t4 using (companynr) where t4.companynr is not null;
 
1357
count(*)
 
1358
1199
 
1359
explain select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null;
 
1360
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1361
1       SIMPLE  t2      ALL     NULL    NULL    NULL    NULL    1200    
 
1362
1       SIMPLE  t4      eq_ref  PRIMARY PRIMARY 1       test.t2.companynr       1       Using where; Not exists
 
1363
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr is null;
 
1364
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1365
1       SIMPLE  t4      ALL     NULL    NULL    NULL    NULL    12      
 
1366
1       SIMPLE  t2      ALL     NULL    NULL    NULL    NULL    1200    Using where; Not exists
 
1367
select companynr,companyname from t2 left join t4 using (companynr) where companynr is null;
 
1368
companynr       companyname
 
1369
select count(*) from t2 left join t4 using (companynr) where companynr is not null;
 
1370
count(*)
 
1371
1200
 
1372
explain select companynr,companyname from t2 left join t4 using (companynr) where companynr is null;
 
1373
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1374
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    Impossible WHERE
 
1375
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr is null;
 
1376
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1377
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    Impossible WHERE
 
1378
delete from t2 where fld1=999999;
 
1379
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0;
 
1380
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1381
1       SIMPLE  t2      ALL     NULL    NULL    NULL    NULL    1199    Using where
 
1382
1       SIMPLE  t4      eq_ref  PRIMARY PRIMARY 1       test.t2.companynr       1       
 
1383
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0;
 
1384
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1385
1       SIMPLE  t2      ALL     NULL    NULL    NULL    NULL    1199    Using where
 
1386
1       SIMPLE  t4      eq_ref  PRIMARY PRIMARY 1       test.t2.companynr       1       
 
1387
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 and t4.companynr > 0;
 
1388
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1389
1       SIMPLE  t2      ALL     NULL    NULL    NULL    NULL    1199    Using where
 
1390
1       SIMPLE  t4      eq_ref  PRIMARY PRIMARY 1       test.t2.companynr       1       
 
1391
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0;
 
1392
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1393
1       SIMPLE  t4      ALL     PRIMARY NULL    NULL    NULL    12      Using where
 
1394
1       SIMPLE  t2      ALL     NULL    NULL    NULL    NULL    1199    
 
1395
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0;
 
1396
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1397
1       SIMPLE  t4      ALL     PRIMARY NULL    NULL    NULL    12      Using where
 
1398
1       SIMPLE  t2      ALL     NULL    NULL    NULL    NULL    1199    
 
1399
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0;
 
1400
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1401
1       SIMPLE  t4      ALL     PRIMARY NULL    NULL    NULL    12      Using where
 
1402
1       SIMPLE  t2      ALL     NULL    NULL    NULL    NULL    1199    
 
1403
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null;
 
1404
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1405
1       SIMPLE  t4      ALL     NULL    NULL    NULL    NULL    12      
 
1406
1       SIMPLE  t2      ALL     NULL    NULL    NULL    NULL    1199    Using where
 
1407
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0 or t4.companynr > 0;
 
1408
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1409
1       SIMPLE  t4      ALL     PRIMARY NULL    NULL    NULL    12      
 
1410
1       SIMPLE  t2      ALL     NULL    NULL    NULL    NULL    1199    Using where
 
1411
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where ifnull(t2.companynr,1)>0;
 
1412
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1413
1       SIMPLE  t4      ALL     NULL    NULL    NULL    NULL    12      
 
1414
1       SIMPLE  t2      ALL     NULL    NULL    NULL    NULL    1199    Using where
 
1415
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null;
 
1416
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1417
1       SIMPLE  t4      ALL     PRIMARY NULL    NULL    NULL    12      Using where
 
1418
1       SIMPLE  t2      ALL     NULL    NULL    NULL    NULL    1199    
 
1419
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0;
 
1420
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1421
1       SIMPLE  t4      ALL     PRIMARY NULL    NULL    NULL    12      Using where
 
1422
1       SIMPLE  t2      ALL     NULL    NULL    NULL    NULL    1199    
 
1423
explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0;
 
1424
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1425
1       SIMPLE  t4      ALL     NULL    NULL    NULL    NULL    12      Using where
 
1426
1       SIMPLE  t2      ALL     NULL    NULL    NULL    NULL    1199    
 
1427
select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1;
 
1428
companynr       companynr
 
1429
37      36
 
1430
41      40
 
1431
explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1;
 
1432
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1433
1       SIMPLE  t4      index   NULL    PRIMARY 1       NULL    12      Using index; Using temporary
 
1434
1       SIMPLE  t2      ALL     NULL    NULL    NULL    NULL    1199    Using where; Using join buffer
 
1435
select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008;
 
1436
fld1    companynr       fld3    period
 
1437
038008  37      reporters       1008
 
1438
038208  37      Selfridge       1008
 
1439
select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009;
 
1440
fld1    companynr       fld3    period
 
1441
038008  37      reporters       1008
 
1442
038208  37      Selfridge       1008
 
1443
select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009;
 
1444
fld1    companynr       fld3    period
 
1445
038008  37      reporters       1008
 
1446
038208  37      Selfridge       1008
 
1447
select period from t1 where (((period > 0) or period < 10000 or (period = 1900)) and (period=1900 and period <= 1901) or (period=1903 and (period=1903)) and period>=1902) or ((period=1904 or period=1905) or (period=1906 or period>1907)) or (period=1908 and period = 1909);
 
1448
period
 
1449
9410
 
1450
select period from t1 where ((period > 0 and period < 1) or (((period > 0 and period < 100) and (period > 10)) or (period > 10)) or (period > 0 and (period > 5 or period > 6)));
 
1451
period
 
1452
9410
 
1453
select a.fld1 from t2 as a,t2 b where ((a.fld1 = 250501 and a.fld1=b.fld1) or a.fld1=250502 or a.fld1=250503 or (a.fld1=250505 and a.fld1<=b.fld1 and b.fld1>=a.fld1)) and a.fld1=b.fld1;
 
1454
fld1
 
1455
250501
 
1456
250502
 
1457
250503
 
1458
250505
 
1459
select fld1 from t2 where fld1 in (250502,98005,98006,250503,250605,250606) and fld1 >=250502 and fld1 not in (250605,250606);
 
1460
fld1
 
1461
250502
 
1462
250503
 
1463
select fld1 from t2 where fld1 between 250502 and 250504;
 
1464
fld1
 
1465
250502
 
1466
250503
 
1467
250504
 
1468
select fld3 from t2 where (((fld3 like "_%L%" ) or (fld3 like "%ok%")) and ( fld3 like "L%" or fld3 like "G%")) and fld3 like "L%" ;
 
1469
fld3
 
1470
label
 
1471
labeled
 
1472
labeled
 
1473
landslide
 
1474
laterally
 
1475
leaflet
 
1476
lewdly
 
1477
Lillian
 
1478
luckily
 
1479
select count(*) from t1;
 
1480
count(*)
 
1481
1
 
1482
select companynr,count(*),sum(fld1) from t2 group by companynr;
 
1483
companynr       count(*)        sum(fld1)
 
1484
00      82      10355753
 
1485
29      95      14473298
 
1486
34      70      17788966
 
1487
36      215     22786296
 
1488
37      588     83602098
 
1489
40      37      6618386
 
1490
41      52      12816335
 
1491
50      11      1595438
 
1492
53      4       793210
 
1493
58      23      2254293
 
1494
65      10      2284055
 
1495
68      12      3097288
 
1496
select companynr,count(*) from t2 group by companynr order by companynr desc limit 5;
 
1497
companynr       count(*)
 
1498
68      12
 
1499
65      10
 
1500
58      23
 
1501
53      4
 
1502
50      11
 
1503
select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>"";
 
1504
count(*)        min(fld4)       max(fld4)       sum(fld1)       avg(fld1)       std(fld1)       variance(fld1)
 
1505
70      absentee        vest    17788966        254128.0857     3272.5940       10709871.3069
 
1506
explain extended select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>"";
 
1507
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
1508
1       SIMPLE  t2      ALL     NULL    NULL    NULL    NULL    1199    100.00  Using where
 
1509
Warnings:
 
1510
Note    1003    select count(0) AS `count(*)`,min(`test`.`t2`.`fld4`) AS `min(fld4)`,max(`test`.`t2`.`fld4`) AS `max(fld4)`,sum(`test`.`t2`.`fld1`) AS `sum(fld1)`,avg(`test`.`t2`.`fld1`) AS `avg(fld1)`,std(`test`.`t2`.`fld1`) AS `std(fld1)`,variance(`test`.`t2`.`fld1`) AS `variance(fld1)` from `test`.`t2` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld4` <> ''))
 
1511
select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr limit 3;
 
1512
companynr       count(*)        min(fld4)       max(fld4)       sum(fld1)       avg(fld1)       std(fld1)       variance(fld1)
 
1513
00      82      Anthony windmills       10355753        126289.6707     115550.9757     13352027981.7087
 
1514
29      95      abut    wetness 14473298        152350.5053     8368.5480       70032594.9026
 
1515
34      70      absentee        vest    17788966        254128.0857     3272.5940       10709871.3069
 
1516
select companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 group by companynr,t2nr limit 10;
 
1517
companynr       t2nr    count(price)    sum(price)      min(price)      max(price)      avg(price)
 
1518
37      1       1       5987435 5987435 5987435 5987435.0000
 
1519
37      2       1       28357832        28357832        28357832        28357832.0000
 
1520
37      3       1       39654943        39654943        39654943        39654943.0000
 
1521
37      11      1       5987435 5987435 5987435 5987435.0000
 
1522
37      12      1       28357832        28357832        28357832        28357832.0000
 
1523
37      13      1       39654943        39654943        39654943        39654943.0000
 
1524
37      21      1       5987435 5987435 5987435 5987435.0000
 
1525
37      22      1       28357832        28357832        28357832        28357832.0000
 
1526
37      23      1       39654943        39654943        39654943        39654943.0000
 
1527
37      31      1       5987435 5987435 5987435 5987435.0000
 
1528
select /*! SQL_SMALL_RESULT */ companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 group by companynr,t2nr limit 10;
 
1529
companynr       t2nr    count(price)    sum(price)      min(price)      max(price)      avg(price)
 
1530
37      1       1       5987435 5987435 5987435 5987435.0000
 
1531
37      2       1       28357832        28357832        28357832        28357832.0000
 
1532
37      3       1       39654943        39654943        39654943        39654943.0000
 
1533
37      11      1       5987435 5987435 5987435 5987435.0000
 
1534
37      12      1       28357832        28357832        28357832        28357832.0000
 
1535
37      13      1       39654943        39654943        39654943        39654943.0000
 
1536
37      21      1       5987435 5987435 5987435 5987435.0000
 
1537
37      22      1       28357832        28357832        28357832        28357832.0000
 
1538
37      23      1       39654943        39654943        39654943        39654943.0000
 
1539
37      31      1       5987435 5987435 5987435 5987435.0000
 
1540
select companynr,count(price),sum(price),min(price),max(price),avg(price) from t3 group by companynr ;
 
1541
companynr       count(price)    sum(price)      min(price)      max(price)      avg(price)
 
1542
37      12543   309394878010    5987435 39654943        24666736.6667
 
1543
78      8362    414611089292    726498  98439034        49582766.0000
 
1544
101     4181    3489454238      834598  834598  834598.0000
 
1545
154     4181    4112197254950   983543950       983543950       983543950.0000
 
1546
311     4181    979599938       234298  234298  234298.0000
 
1547
447     4181    9929180954      2374834 2374834 2374834.0000
 
1548
512     4181    3288532102      786542  786542  786542.0000
 
1549
select distinct mod(companynr,10) from t4 group by companynr;
 
1550
mod(companynr,10)
 
1551
0
 
1552
9
 
1553
4
 
1554
6
 
1555
7
 
1556
1
 
1557
3
 
1558
8
 
1559
5
 
1560
select distinct 1 from t4 group by companynr;
 
1561
1
 
1562
1
 
1563
select count(distinct fld1) from t2;
 
1564
count(distinct fld1)
 
1565
1199
 
1566
select companynr,count(distinct fld1) from t2 group by companynr;
 
1567
companynr       count(distinct fld1)
 
1568
00      82
 
1569
29      95
 
1570
34      70
 
1571
36      215
 
1572
37      588
 
1573
40      37
 
1574
41      52
 
1575
50      11
 
1576
53      4
 
1577
58      23
 
1578
65      10
 
1579
68      12
 
1580
select companynr,count(*) from t2 group by companynr;
 
1581
companynr       count(*)
 
1582
00      82
 
1583
29      95
 
1584
34      70
 
1585
36      215
 
1586
37      588
 
1587
40      37
 
1588
41      52
 
1589
50      11
 
1590
53      4
 
1591
58      23
 
1592
65      10
 
1593
68      12
 
1594
select companynr,count(distinct concat(fld1,repeat(65,1000))) from t2 group by companynr;
 
1595
companynr       count(distinct concat(fld1,repeat(65,1000)))
 
1596
00      82
 
1597
29      95
 
1598
34      70
 
1599
36      215
 
1600
37      588
 
1601
40      37
 
1602
41      52
 
1603
50      11
 
1604
53      4
 
1605
58      23
 
1606
65      10
 
1607
68      12
 
1608
select companynr,count(distinct concat(fld1,repeat(65,200))) from t2 group by companynr;
 
1609
companynr       count(distinct concat(fld1,repeat(65,200)))
 
1610
00      82
 
1611
29      95
 
1612
34      70
 
1613
36      215
 
1614
37      588
 
1615
40      37
 
1616
41      52
 
1617
50      11
 
1618
53      4
 
1619
58      23
 
1620
65      10
 
1621
68      12
 
1622
select companynr,count(distinct floor(fld1/100)) from t2 group by companynr;
 
1623
companynr       count(distinct floor(fld1/100))
 
1624
00      47
 
1625
29      35
 
1626
34      14
 
1627
36      69
 
1628
37      108
 
1629
40      16
 
1630
41      11
 
1631
50      9
 
1632
53      1
 
1633
58      1
 
1634
65      1
 
1635
68      1
 
1636
select companynr,count(distinct concat(repeat(65,1000),floor(fld1/100))) from t2 group by companynr;
 
1637
companynr       count(distinct concat(repeat(65,1000),floor(fld1/100)))
 
1638
00      47
 
1639
29      35
 
1640
34      14
 
1641
36      69
 
1642
37      108
 
1643
40      16
 
1644
41      11
 
1645
50      9
 
1646
53      1
 
1647
58      1
 
1648
65      1
 
1649
68      1
 
1650
select sum(fld1),fld3 from t2 where fld3="Romans" group by fld1 limit 10;
 
1651
sum(fld1)       fld3
 
1652
11402   Romans
 
1653
select name,count(*) from t3 where name='cloakroom' group by name;
 
1654
name    count(*)
 
1655
cloakroom       4181
 
1656
select name,count(*) from t3 where name='cloakroom' and price>10 group by name;
 
1657
name    count(*)
 
1658
cloakroom       4181
 
1659
select count(*) from t3 where name='cloakroom' and price2=823742;
 
1660
count(*)
 
1661
4181
 
1662
select name,count(*) from t3 where name='cloakroom' and price2=823742 group by name;
 
1663
name    count(*)
 
1664
cloakroom       4181
 
1665
select name,count(*) from t3 where name >= "extramarital" and price <= 39654943 group by name;
 
1666
name    count(*)
 
1667
extramarital    4181
 
1668
gazer   4181
 
1669
gems    4181
 
1670
Iranizes        4181
 
1671
spates  4181
 
1672
tucked  4181
 
1673
violinist       4181
 
1674
select t2.fld3,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name;
 
1675
fld3    count(*)
 
1676
spates  4181
 
1677
select companynr|0,companyname from t4 group by 1;
 
1678
companynr|0     companyname
 
1679
0       Unknown
 
1680
29      company 1
 
1681
34      company 2
 
1682
36      company 3
 
1683
37      company 4
 
1684
40      company 5
 
1685
41      company 6
 
1686
50      company 11
 
1687
53      company 7
 
1688
58      company 8
 
1689
65      company 9
 
1690
68      company 10
 
1691
select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by t2.companynr order by companyname;
 
1692
companynr       companyname     count(*)
 
1693
29      company 1       95
 
1694
68      company 10      12
 
1695
50      company 11      11
 
1696
34      company 2       70
 
1697
36      company 3       215
 
1698
37      company 4       588
 
1699
40      company 5       37
 
1700
41      company 6       52
 
1701
53      company 7       4
 
1702
58      company 8       23
 
1703
65      company 9       10
 
1704
00      Unknown 82
 
1705
select t2.fld1,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name;
 
1706
fld1    count(*)
 
1707
158402  4181
 
1708
select sum(Period)/count(*) from t1;
 
1709
sum(Period)/count(*)
 
1710
9410.0000
 
1711
select companynr,count(price) as "count",sum(price) as "sum" ,abs(sum(price)/count(price)-avg(price)) as "diff",(0+count(price))*companynr as func from t3 group by companynr;
 
1712
companynr       count   sum     diff    func
 
1713
37      12543   309394878010    0.0000  464091
 
1714
78      8362    414611089292    0.0000  652236
 
1715
101     4181    3489454238      0.0000  422281
 
1716
154     4181    4112197254950   0.0000  643874
 
1717
311     4181    979599938       0.0000  1300291
 
1718
447     4181    9929180954      0.0000  1868907
 
1719
512     4181    3288532102      0.0000  2140672
 
1720
select companynr,sum(price)/count(price) as avg from t3 group by companynr having avg > 70000000 order by avg;
 
1721
companynr       avg
 
1722
154     983543950.0000
 
1723
select companynr,count(*) from t2 group by companynr order by 2 desc;
 
1724
companynr       count(*)
 
1725
37      588
 
1726
36      215
 
1727
29      95
 
1728
00      82
 
1729
34      70
 
1730
41      52
 
1731
40      37
 
1732
58      23
 
1733
68      12
 
1734
50      11
 
1735
65      10
 
1736
53      4
 
1737
select companynr,count(*) from t2 where companynr > 40 group by companynr order by 2 desc;
 
1738
companynr       count(*)
 
1739
41      52
 
1740
58      23
 
1741
68      12
 
1742
50      11
 
1743
65      10
 
1744
53      4
 
1745
select t2.fld4,t2.fld1,count(price),sum(price),min(price),max(price),avg(price) from t3,t2 where t3.companynr = 37 and t2.fld1 = t3.t2nr group by fld1,t2.fld4;
 
1746
fld4    fld1    count(price)    sum(price)      min(price)      max(price)      avg(price)
 
1747
teethe  000001  1       5987435 5987435 5987435 5987435.0000
 
1748
dreaded 011401  1       5987435 5987435 5987435 5987435.0000
 
1749
scholastics     011402  1       28357832        28357832        28357832        28357832.0000
 
1750
audiology       011403  1       39654943        39654943        39654943        39654943.0000
 
1751
wallet  011501  1       5987435 5987435 5987435 5987435.0000
 
1752
parters 011701  1       5987435 5987435 5987435 5987435.0000
 
1753
eschew  011702  1       28357832        28357832        28357832        28357832.0000
 
1754
quitter 011703  1       39654943        39654943        39654943        39654943.0000
 
1755
neat    012001  1       5987435 5987435 5987435 5987435.0000
 
1756
Steinberg       012003  1       39654943        39654943        39654943        39654943.0000
 
1757
balled  012301  1       5987435 5987435 5987435 5987435.0000
 
1758
persist 012302  1       28357832        28357832        28357832        28357832.0000
 
1759
attainments     012303  1       39654943        39654943        39654943        39654943.0000
 
1760
capably 012501  1       5987435 5987435 5987435 5987435.0000
 
1761
impulsive       012602  1       28357832        28357832        28357832        28357832.0000
 
1762
starlet 012603  1       39654943        39654943        39654943        39654943.0000
 
1763
featherweight   012701  1       5987435 5987435 5987435 5987435.0000
 
1764
pessimist       012702  1       28357832        28357832        28357832        28357832.0000
 
1765
daughter        012703  1       39654943        39654943        39654943        39654943.0000
 
1766
lawgiver        013601  1       5987435 5987435 5987435 5987435.0000
 
1767
stated  013602  1       28357832        28357832        28357832        28357832.0000
 
1768
readable        013603  1       39654943        39654943        39654943        39654943.0000
 
1769
testicle        013801  1       5987435 5987435 5987435 5987435.0000
 
1770
Parsifal        013802  1       28357832        28357832        28357832        28357832.0000
 
1771
leavings        013803  1       39654943        39654943        39654943        39654943.0000
 
1772
squeaking       013901  1       5987435 5987435 5987435 5987435.0000
 
1773
contrasted      016001  1       5987435 5987435 5987435 5987435.0000
 
1774
leftover        016201  1       5987435 5987435 5987435 5987435.0000
 
1775
whiteners       016202  1       28357832        28357832        28357832        28357832.0000
 
1776
erases  016301  1       5987435 5987435 5987435 5987435.0000
 
1777
Punjab  016302  1       28357832        28357832        28357832        28357832.0000
 
1778
Merritt 016303  1       39654943        39654943        39654943        39654943.0000
 
1779
sweetish        018001  1       5987435 5987435 5987435 5987435.0000
 
1780
dogging 018002  1       28357832        28357832        28357832        28357832.0000
 
1781
scornfully      018003  1       39654943        39654943        39654943        39654943.0000
 
1782
fetters 018012  1       28357832        28357832        28357832        28357832.0000
 
1783
bivalves        018013  1       39654943        39654943        39654943        39654943.0000
 
1784
skulking        018021  1       5987435 5987435 5987435 5987435.0000
 
1785
flint   018022  1       28357832        28357832        28357832        28357832.0000
 
1786
flopping        018023  1       39654943        39654943        39654943        39654943.0000
 
1787
Judas   018032  1       28357832        28357832        28357832        28357832.0000
 
1788
vacuuming       018033  1       39654943        39654943        39654943        39654943.0000
 
1789
medical 018041  1       5987435 5987435 5987435 5987435.0000
 
1790
bloodbath       018042  1       28357832        28357832        28357832        28357832.0000
 
1791
subschema       018043  1       39654943        39654943        39654943        39654943.0000
 
1792
interdependent  018051  1       5987435 5987435 5987435 5987435.0000
 
1793
Graves  018052  1       28357832        28357832        28357832        28357832.0000
 
1794
neonatal        018053  1       39654943        39654943        39654943        39654943.0000
 
1795
sorters 018061  1       5987435 5987435 5987435 5987435.0000
 
1796
epistle 018062  1       28357832        28357832        28357832        28357832.0000
 
1797
Conley  018101  1       5987435 5987435 5987435 5987435.0000
 
1798
lectured        018102  1       28357832        28357832        28357832        28357832.0000
 
1799
Abraham 018103  1       39654943        39654943        39654943        39654943.0000
 
1800
cage    018201  1       5987435 5987435 5987435 5987435.0000
 
1801
hushes  018202  1       28357832        28357832        28357832        28357832.0000
 
1802
Simla   018402  1       28357832        28357832        28357832        28357832.0000
 
1803
reporters       018403  1       39654943        39654943        39654943        39654943.0000
 
1804
coexist 018601  1       5987435 5987435 5987435 5987435.0000
 
1805
Beebe   018602  1       28357832        28357832        28357832        28357832.0000
 
1806
Taoism  018603  1       39654943        39654943        39654943        39654943.0000
 
1807
Connally        018801  1       5987435 5987435 5987435 5987435.0000
 
1808
fetched 018802  1       28357832        28357832        28357832        28357832.0000
 
1809
checkpoints     018803  1       39654943        39654943        39654943        39654943.0000
 
1810
gritty  018811  1       5987435 5987435 5987435 5987435.0000
 
1811
firearm 018812  1       28357832        28357832        28357832        28357832.0000
 
1812
minima  019101  1       5987435 5987435 5987435 5987435.0000
 
1813
Selfridge       019102  1       28357832        28357832        28357832        28357832.0000
 
1814
disable 019103  1       39654943        39654943        39654943        39654943.0000
 
1815
witchcraft      019201  1       5987435 5987435 5987435 5987435.0000
 
1816
betroth 030501  1       5987435 5987435 5987435 5987435.0000
 
1817
Manhattanize    030502  1       28357832        28357832        28357832        28357832.0000
 
1818
imprint 030503  1       39654943        39654943        39654943        39654943.0000
 
1819
swelling        031901  1       5987435 5987435 5987435 5987435.0000
 
1820
interrelationships      036001  1       5987435 5987435 5987435 5987435.0000
 
1821
riser   036002  1       28357832        28357832        28357832        28357832.0000
 
1822
bee     038001  1       5987435 5987435 5987435 5987435.0000
 
1823
kanji   038002  1       28357832        28357832        28357832        28357832.0000
 
1824
dental  038003  1       39654943        39654943        39654943        39654943.0000
 
1825
railway 038011  1       5987435 5987435 5987435 5987435.0000
 
1826
validate        038012  1       28357832        28357832        28357832        28357832.0000
 
1827
normalizes      038013  1       39654943        39654943        39654943        39654943.0000
 
1828
Kline   038101  1       5987435 5987435 5987435 5987435.0000
 
1829
Anatole 038102  1       28357832        28357832        28357832        28357832.0000
 
1830
partridges      038103  1       39654943        39654943        39654943        39654943.0000
 
1831
recruited       038201  1       5987435 5987435 5987435 5987435.0000
 
1832
dimensions      038202  1       28357832        28357832        28357832        28357832.0000
 
1833
Chicana 038203  1       39654943        39654943        39654943        39654943.0000
 
1834
select t3.companynr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 group by companynr,fld3;
 
1835
companynr       fld3    sum(price)
 
1836
512     boat    786542
 
1837
512     capably 786542
 
1838
512     cupboard        786542
 
1839
512     decliner        786542
 
1840
512     descendants     786542
 
1841
512     dopers  786542
 
1842
512     erases  786542
 
1843
512     Micronesia      786542
 
1844
512     Miles   786542
 
1845
512     skies   786542
 
1846
select t2.companynr,count(*),min(fld3),max(fld3),sum(price),avg(price) from t2,t3 where t3.companynr >= 30 and t3.companynr <= 58 and t3.t2nr = t2.fld1 and 1+1=2 group by t2.companynr;
 
1847
companynr       count(*)        min(fld3)       max(fld3)       sum(price)      avg(price)
 
1848
00      1       Omaha   Omaha   5987435 5987435.0000
 
1849
36      1       dubbed  dubbed  28357832        28357832.0000
 
1850
37      83      Abraham Wotan   1908978016      22999735.1325
 
1851
50      2       scribbled       tapestry        68012775        34006387.5000
 
1852
select t3.companynr+0,t3.t2nr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 37 group by 1,t3.t2nr,fld3,fld3,fld3,fld3,fld3 order by fld1;
 
1853
t3.companynr+0  t2nr    fld3    sum(price)
 
1854
37      1       Omaha   5987435
 
1855
37      11401   breaking        5987435
 
1856
37      11402   Romans  28357832
 
1857
37      11403   intercepted     39654943
 
1858
37      11501   bewilderingly   5987435
 
1859
37      11701   astound 5987435
 
1860
37      11702   admonishing     28357832
 
1861
37      11703   sumac   39654943
 
1862
37      12001   flanking        5987435
 
1863
37      12003   combed  39654943
 
1864
37      12301   Eulerian        5987435
 
1865
37      12302   dubbed  28357832
 
1866
37      12303   Kane    39654943
 
1867
37      12501   annihilates     5987435
 
1868
37      12602   Wotan   28357832
 
1869
37      12603   snatching       39654943
 
1870
37      12701   grazing 5987435
 
1871
37      12702   Baird   28357832
 
1872
37      12703   celery  39654943
 
1873
37      13601   handgun 5987435
 
1874
37      13602   foldout 28357832
 
1875
37      13603   mystic  39654943
 
1876
37      13801   intelligibility 5987435
 
1877
37      13802   Augustine       28357832
 
1878
37      13803   teethe  39654943
 
1879
37      13901   scholastics     5987435
 
1880
37      16001   audiology       5987435
 
1881
37      16201   wallet  5987435
 
1882
37      16202   parters 28357832
 
1883
37      16301   eschew  5987435
 
1884
37      16302   quitter 28357832
 
1885
37      16303   neat    39654943
 
1886
37      18001   jarring 5987435
 
1887
37      18002   tinily  28357832
 
1888
37      18003   balled  39654943
 
1889
37      18012   impulsive       28357832
 
1890
37      18013   starlet 39654943
 
1891
37      18021   lawgiver        5987435
 
1892
37      18022   stated  28357832
 
1893
37      18023   readable        39654943
 
1894
37      18032   testicle        28357832
 
1895
37      18033   Parsifal        39654943
 
1896
37      18041   Punjab  5987435
 
1897
37      18042   Merritt 28357832
 
1898
37      18043   Quixotism       39654943
 
1899
37      18051   sureties        5987435
 
1900
37      18052   puddings        28357832
 
1901
37      18053   tapestry        39654943
 
1902
37      18061   trimmings       5987435
 
1903
37      18062   humility        28357832
 
1904
37      18101   tragedies       5987435
 
1905
37      18102   skulking        28357832
 
1906
37      18103   flint   39654943
 
1907
37      18201   relaxing        5987435
 
1908
37      18202   offload 28357832
 
1909
37      18402   suites  28357832
 
1910
37      18403   lists   39654943
 
1911
37      18601   vacuuming       5987435
 
1912
37      18602   dentally        28357832
 
1913
37      18603   humanness       39654943
 
1914
37      18801   inch    5987435
 
1915
37      18802   Weissmuller     28357832
 
1916
37      18803   irresponsibly   39654943
 
1917
37      18811   repetitions     5987435
 
1918
37      18812   Antares 28357832
 
1919
37      19101   ventilate       5987435
 
1920
37      19102   pityingly       28357832
 
1921
37      19103   interdependent  39654943
 
1922
37      19201   Graves  5987435
 
1923
37      30501   neonatal        5987435
 
1924
37      30502   scribbled       28357832
 
1925
37      30503   chafe   39654943
 
1926
37      31901   realtor 5987435
 
1927
37      36001   elite   5987435
 
1928
37      36002   funereal        28357832
 
1929
37      38001   Conley  5987435
 
1930
37      38002   lectured        28357832
 
1931
37      38003   Abraham 39654943
 
1932
37      38011   groupings       5987435
 
1933
37      38012   dissociate      28357832
 
1934
37      38013   coexist 39654943
 
1935
37      38101   rusting 5987435
 
1936
37      38102   galling 28357832
 
1937
37      38103   obliterates     39654943
 
1938
37      38201   resumes 5987435
 
1939
37      38202   analyzable      28357832
 
1940
37      38203   terminator      39654943
 
1941
select sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1= t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008;
 
1942
sum(price)
 
1943
234298
 
1944
select t2.fld1,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1 = t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008 or t3.t2nr = t2.fld1 and t2.fld1 = 38008 group by t2.fld1;
 
1945
fld1    sum(price)
 
1946
038008  234298
 
1947
explain select fld3 from t2 where 1>2 or 2>3;
 
1948
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1949
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    Impossible WHERE
 
1950
explain select fld3 from t2 where fld1=fld1;
 
1951
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1952
1       SIMPLE  t2      ALL     NULL    NULL    NULL    NULL    1199    
 
1953
select companynr,fld1 from t2 HAVING fld1=250501 or fld1=250502;
 
1954
companynr       fld1
 
1955
34      250501
 
1956
34      250502
 
1957
select companynr,fld1 from t2 WHERE fld1>=250501 HAVING fld1<=250502;
 
1958
companynr       fld1
 
1959
34      250501
 
1960
34      250502
 
1961
select companynr,count(*) as count,sum(fld1) as sum from t2 group by companynr having count > 40 and sum/count >= 120000;
 
1962
companynr       count   sum
 
1963
00      82      10355753
 
1964
29      95      14473298
 
1965
34      70      17788966
 
1966
37      588     83602098
 
1967
41      52      12816335
 
1968
select companynr from t2 group by companynr having count(*) > 40 and sum(fld1)/count(*) >= 120000 ;
 
1969
companynr
 
1970
00
 
1971
29
 
1972
34
 
1973
37
 
1974
41
 
1975
select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by companyname having t2.companynr >= 40;
 
1976
companynr       companyname     count(*)
 
1977
68      company 10      12
 
1978
50      company 11      11
 
1979
40      company 5       37
 
1980
41      company 6       52
 
1981
53      company 7       4
 
1982
58      company 8       23
 
1983
65      company 9       10
 
1984
select count(*) from t2;
 
1985
count(*)
 
1986
1199
 
1987
select count(*) from t2 where fld1 < 098024;
 
1988
count(*)
 
1989
387
 
1990
select min(fld1) from t2 where fld1>= 098024;
 
1991
min(fld1)
 
1992
98024
 
1993
select max(fld1) from t2 where fld1>= 098024;
 
1994
max(fld1)
 
1995
1232609
 
1996
select count(*) from t3 where price2=76234234;
 
1997
count(*)
 
1998
4181
 
1999
select count(*) from t3 where companynr=512 and price2=76234234;
 
2000
count(*)
 
2001
4181
 
2002
explain select min(fld1),max(fld1),count(*) from t2;
 
2003
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
2004
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    Select tables optimized away
 
2005
select min(fld1),max(fld1),count(*) from t2;
 
2006
min(fld1)       max(fld1)       count(*)
 
2007
0       1232609 1199
 
2008
select min(t2nr),max(t2nr) from t3 where t2nr=2115 and price2=823742;
 
2009
min(t2nr)       max(t2nr)
 
2010
2115    2115
 
2011
select count(*),min(t2nr),max(t2nr) from t3 where name='spates' and companynr=78;
 
2012
count(*)        min(t2nr)       max(t2nr)
 
2013
4181    4       41804
 
2014
select t2nr,count(*) from t3 where name='gems' group by t2nr limit 20;
 
2015
t2nr    count(*)
 
2016
9       1
 
2017
19      1
 
2018
29      1
 
2019
39      1
 
2020
49      1
 
2021
59      1
 
2022
69      1
 
2023
79      1
 
2024
89      1
 
2025
99      1
 
2026
109     1
 
2027
119     1
 
2028
129     1
 
2029
139     1
 
2030
149     1
 
2031
159     1
 
2032
169     1
 
2033
179     1
 
2034
189     1
 
2035
199     1
 
2036
select max(t2nr) from t3 where price=983543950;
 
2037
max(t2nr)
 
2038
41807
 
2039
select t1.period from t3 = t1 limit 1;
 
2040
period
 
2041
1001
 
2042
select t1.period from t1 as t1 limit 1;
 
2043
period
 
2044
9410
 
2045
select t1.period as "Nuvarande period" from t1 as t1 limit 1;
 
2046
Nuvarande period
 
2047
9410
 
2048
select period as ok_period from t1 limit 1;
 
2049
ok_period
 
2050
9410
 
2051
select period as ok_period from t1 group by ok_period limit 1;
 
2052
ok_period
 
2053
9410
 
2054
select 1+1 as summa from t1 group by summa limit 1;
 
2055
summa
 
2056
2
 
2057
select period as "Nuvarande period" from t1 group by "Nuvarande period" limit 1;
 
2058
Nuvarande period
 
2059
9410
 
2060
show tables;
 
2061
Tables_in_test
 
2062
t1
 
2063
t2
 
2064
t3
 
2065
t4
 
2066
show tables from test like "s%";
 
2067
Tables_in_test (s%)
 
2068
show tables from test like "t?";
 
2069
Tables_in_test (t?)
 
2070
show full columns from t2;
 
2071
Field   Type    Collation       Null    Key     Default Extra   Privileges      Comment
 
2072
auto    int(11) NULL    NO      PRI     NULL    auto_increment  #       
 
2073
fld1    int(6) unsigned zerofill        NULL    NO      UNI     000000          #       
 
2074
companynr       tinyint(2) unsigned zerofill    NULL    NO              00              #       
 
2075
fld3    char(30)        latin1_swedish_ci       NO      MUL                     #       
 
2076
fld4    char(35)        latin1_swedish_ci       NO                              #       
 
2077
fld5    char(35)        latin1_swedish_ci       NO                              #       
 
2078
fld6    char(4) latin1_swedish_ci       NO                              #       
 
2079
show full columns from t2 from test like 'f%';
 
2080
Field   Type    Collation       Null    Key     Default Extra   Privileges      Comment
 
2081
fld1    int(6) unsigned zerofill        NULL    NO      UNI     000000          #       
 
2082
fld3    char(30)        latin1_swedish_ci       NO      MUL                     #       
 
2083
fld4    char(35)        latin1_swedish_ci       NO                              #       
 
2084
fld5    char(35)        latin1_swedish_ci       NO                              #       
 
2085
fld6    char(4) latin1_swedish_ci       NO                              #       
 
2086
show full columns from t2 from test like 's%';
 
2087
Field   Type    Collation       Null    Key     Default Extra   Privileges      Comment
 
2088
show keys from t2;
 
2089
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment
 
2090
t2      0       PRIMARY 1       auto    A       1199    NULL    NULL            BTREE   
 
2091
t2      0       fld1    1       fld1    A       1199    NULL    NULL            BTREE   
 
2092
t2      1       fld3    1       fld3    A       NULL    NULL    NULL            BTREE   
 
2093
drop table t4, t3, t2, t1;
 
2094
DO 1;
 
2095
DO benchmark(100,1+1),1,1;
 
2096
do default;
 
2097
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
 
2098
do foobar;
 
2099
ERROR 42S22: Unknown column 'foobar' in 'field list'
 
2100
CREATE TABLE t1 (
 
2101
id mediumint(8) unsigned NOT NULL auto_increment,
 
2102
pseudo varchar(35) NOT NULL default '',
 
2103
PRIMARY KEY  (id),
 
2104
UNIQUE KEY pseudo (pseudo)
 
2105
);
 
2106
INSERT INTO t1 (pseudo) VALUES ('test');
 
2107
INSERT INTO t1 (pseudo) VALUES ('test1');
 
2108
SELECT 1 as rnd1 from t1 where rand() > 2;
 
2109
rnd1
 
2110
DROP TABLE t1;
 
2111
CREATE TABLE t1 (gvid int(10) unsigned default NULL,  hmid int(10) unsigned default NULL,  volid int(10) unsigned default NULL,  mmid int(10) unsigned default NULL,  hdid int(10) unsigned default NULL,  fsid int(10) unsigned default NULL,  ctid int(10) unsigned default NULL,  dtid int(10) unsigned default NULL,  cost int(10) unsigned default NULL,  performance int(10) unsigned default NULL,  serialnumber bigint(20) unsigned default NULL,  monitored tinyint(3) unsigned default '1',  removed tinyint(3) unsigned default '0',  target tinyint(3) unsigned default '0',  dt_modified timestamp NOT NULL,  name varchar(255) binary default NULL,  description varchar(255) default NULL,  UNIQUE KEY hmid (hmid,volid)) ENGINE=MyISAM;
 
2112
INSERT INTO t1 VALUES (200001,2,1,1,100,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\E$',''),(200002,2,2,1,101,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\C$',''),(200003,1,3,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,1,0,1,20020425060427,'c:',NULL);
 
2113
CREATE TABLE t2 (  hmid int(10) unsigned default NULL,  volid int(10) unsigned default NULL,  sampletid smallint(5) unsigned default NULL,  sampletime datetime default NULL,  samplevalue bigint(20) unsigned default NULL,  KEY idx1 (hmid,volid,sampletid,sampletime)) ENGINE=MyISAM;
 
2114
INSERT INTO t2 VALUES (1,3,10,'2002-06-01 08:00:00',35),(1,3,1010,'2002-06-01 12:00:01',35);
 
2115
SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= 'wrong-date-value' AND b.sampletime < 'wrong-date-value' AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid;
 
2116
gvid    the_success     the_fail        the_size        the_time
 
2117
Warnings:
 
2118
Warning 1292    Incorrect datetime value: 'wrong-date-value' for column 'sampletime' at row 1
 
2119
Warning 1292    Incorrect datetime value: 'wrong-date-value' for column 'sampletime' at row 1
 
2120
SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= NULL AND b.sampletime < NULL AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid;
 
2121
gvid    the_success     the_fail        the_size        the_time
 
2122
DROP TABLE t1,t2;
 
2123
create table  t1 (  A_Id bigint(20) NOT NULL default '0',  A_UpdateBy char(10) NOT NULL default '',  A_UpdateDate bigint(20) NOT NULL default '0',  A_UpdateSerial int(11) NOT NULL default '0',  other_types bigint(20) NOT NULL default '0',  wss_type bigint(20) NOT NULL default '0');
 
2124
INSERT INTO t1 VALUES (102935998719055004,'brade',1029359987,2,102935229116544068,102935229216544093);
 
2125
select wss_type from t1 where wss_type ='102935229216544106';
 
2126
wss_type
 
2127
select wss_type from t1 where wss_type ='102935229216544105';
 
2128
wss_type
 
2129
select wss_type from t1 where wss_type ='102935229216544104';
 
2130
wss_type
 
2131
select wss_type from t1 where wss_type ='102935229216544093';
 
2132
wss_type
 
2133
102935229216544093
 
2134
select wss_type from t1 where wss_type =102935229216544093;
 
2135
wss_type
 
2136
102935229216544093
 
2137
drop table t1;
 
2138
select 1+2,"aaaa",3.13*2.0 into @a,@b,@c;
 
2139
select @a;
 
2140
@a
 
2141
3
 
2142
select @b;
 
2143
@b
 
2144
aaaa
 
2145
select @c;
 
2146
@c
 
2147
6.260
 
2148
create table t1 (a int not null auto_increment primary key);
 
2149
insert into t1 values ();
 
2150
insert into t1 values ();
 
2151
insert into t1 values ();
 
2152
select * from (t1 as t2 left join t1 as t3 using (a)), t1;
 
2153
a       a
 
2154
1       1
 
2155
2       1
 
2156
3       1
 
2157
1       2
 
2158
2       2
 
2159
3       2
 
2160
1       3
 
2161
2       3
 
2162
3       3
 
2163
select * from t1, (t1 as t2 left join t1 as t3 using (a));
 
2164
a       a
 
2165
1       1
 
2166
2       1
 
2167
3       1
 
2168
1       2
 
2169
2       2
 
2170
3       2
 
2171
1       3
 
2172
2       3
 
2173
3       3
 
2174
select * from (t1 as t2 left join t1 as t3 using (a)) straight_join t1;
 
2175
a       a
 
2176
1       1
 
2177
2       1
 
2178
3       1
 
2179
1       2
 
2180
2       2
 
2181
3       2
 
2182
1       3
 
2183
2       3
 
2184
3       3
 
2185
select * from t1 straight_join (t1 as t2 left join t1 as t3 using (a));
 
2186
a       a
 
2187
1       1
 
2188
2       1
 
2189
3       1
 
2190
1       2
 
2191
2       2
 
2192
3       2
 
2193
1       3
 
2194
2       3
 
2195
3       3
 
2196
select * from (t1 as t2 left join t1 as t3 using (a)) inner join t1 on t1.a>1;
 
2197
a       a
 
2198
1       2
 
2199
1       3
 
2200
2       2
 
2201
2       3
 
2202
3       2
 
2203
3       3
 
2204
select * from t1 inner join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1;
 
2205
a       a
 
2206
2       1
 
2207
3       1
 
2208
2       2
 
2209
3       2
 
2210
2       3
 
2211
3       3
 
2212
select * from (t1 as t2 left join t1 as t3 using (a)) inner join t1 using ( a );
 
2213
a
 
2214
1
 
2215
2
 
2216
3
 
2217
select * from t1 inner join (t1 as t2 left join t1 as t3 using (a)) using ( a );
 
2218
a
 
2219
1
 
2220
2
 
2221
3
 
2222
select * from (t1 as t2 left join t1 as t3 using (a)) left outer join t1 on t1.a>1;
 
2223
a       a
 
2224
1       2
 
2225
1       3
 
2226
2       2
 
2227
2       3
 
2228
3       2
 
2229
3       3
 
2230
select * from t1 left outer join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1;
 
2231
a       a
 
2232
1       NULL
 
2233
2       1
 
2234
2       2
 
2235
2       3
 
2236
3       1
 
2237
3       2
 
2238
3       3
 
2239
select * from (t1 as t2 left join t1 as t3 using (a)) left join t1 using ( a );
 
2240
a
 
2241
1
 
2242
2
 
2243
3
 
2244
select * from t1 left join (t1 as t2 left join t1 as t3 using (a)) using ( a );
 
2245
a
 
2246
1
 
2247
2
 
2248
3
 
2249
select * from (t1 as t2 left join t1 as t3 using (a)) natural left join t1;
 
2250
a
 
2251
1
 
2252
2
 
2253
3
 
2254
select * from t1 natural left join (t1 as t2 left join t1 as t3 using (a));
 
2255
a
 
2256
1
 
2257
2
 
2258
3
 
2259
select * from (t1 as t2 left join t1 as t3 using (a)) right join t1 on t1.a>1;
 
2260
a       a
 
2261
NULL    1
 
2262
1       2
 
2263
2       2
 
2264
3       2
 
2265
1       3
 
2266
2       3
 
2267
3       3
 
2268
select * from t1 right join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1;
 
2269
a       a
 
2270
2       1
 
2271
3       1
 
2272
2       2
 
2273
3       2
 
2274
2       3
 
2275
3       3
 
2276
select * from (t1 as t2 left join t1 as t3 using (a)) right outer join t1 using ( a );
 
2277
a
 
2278
1
 
2279
2
 
2280
3
 
2281
select * from t1 right outer join (t1 as t2 left join t1 as t3 using (a)) using ( a );
 
2282
a
 
2283
1
 
2284
2
 
2285
3
 
2286
select * from (t1 as t2 left join t1 as t3 using (a)) natural right join t1;
 
2287
a
 
2288
1
 
2289
2
 
2290
3
 
2291
select * from t1 natural right join (t1 as t2 left join t1 as t3 using (a));
 
2292
a
 
2293
1
 
2294
2
 
2295
3
 
2296
select * from t1 natural join (t1 as t2 left join t1 as t3 using (a));
 
2297
a
 
2298
1
 
2299
2
 
2300
3
 
2301
select * from (t1 as t2 left join t1 as t3 using (a)) natural join t1;
 
2302
a
 
2303
1
 
2304
2
 
2305
3
 
2306
drop table t1;
 
2307
CREATE TABLE t1 (  aa char(2),  id int(11) NOT NULL auto_increment,  t2_id int(11) NOT NULL default '0',  PRIMARY KEY  (id),  KEY replace_id (t2_id)) ENGINE=MyISAM;
 
2308
INSERT INTO t1 VALUES ("1",8264,2506),("2",8299,2517),("3",8301,2518),("4",8302,2519),("5",8303,2520),("6",8304,2521),("7",8305,2522);
 
2309
CREATE TABLE t2 ( id int(11) NOT NULL auto_increment,  PRIMARY KEY  (id)) ENGINE=MyISAM;
 
2310
INSERT INTO t2 VALUES (2517), (2518), (2519), (2520), (2521), (2522);
 
2311
select * from t1, t2 WHERE t1.t2_id = t2.id and t1.t2_id > 0   order by t1.id   LIMIT 0, 5;
 
2312
aa      id      t2_id   id
 
2313
2       8299    2517    2517
 
2314
3       8301    2518    2518
 
2315
4       8302    2519    2519
 
2316
5       8303    2520    2520
 
2317
6       8304    2521    2521
 
2318
drop table t1,t2;
 
2319
create table t1 (id1 int NOT NULL);
 
2320
create table t2 (id2 int NOT NULL);
 
2321
create table t3 (id3 int NOT NULL);
 
2322
create table t4 (id4 int NOT NULL, id44 int NOT NULL, KEY (id4));
 
2323
insert into t1 values (1);
 
2324
insert into t1 values (2);
 
2325
insert into t2 values (1);
 
2326
insert into t4 values (1,1);
 
2327
explain select * from t1 left join t2 on id1 = id2 left join t3 on id1 = id3
 
2328
left join t4 on id3 = id4 where id2 = 1 or id4 = 1;
 
2329
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
2330
1       SIMPLE  t3      system  NULL    NULL    NULL    NULL    0       const row not found
 
2331
1       SIMPLE  t4      const   id4     NULL    NULL    NULL    1       
 
2332
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    2       
 
2333
1       SIMPLE  t2      ALL     NULL    NULL    NULL    NULL    1       Using where
 
2334
select * from t1 left join t2 on id1 = id2 left join t3 on id1 = id3
 
2335
left join t4 on id3 = id4 where id2 = 1 or id4 = 1;
 
2336
id1     id2     id3     id4     id44
 
2337
1       1       NULL    NULL    NULL
 
2338
drop table t1,t2,t3,t4;
 
2339
create table t1(s varchar(10) not null);
 
2340
create table t2(s varchar(10) not null primary key);
 
2341
create table t3(s varchar(10) not null primary key);
 
2342
insert into t1 values ('one\t'), ('two\t');
 
2343
insert into t2 values ('one\r'), ('two\t');
 
2344
insert into t3 values ('one '), ('two\t');
 
2345
select * from t1 where s = 'one';
 
2346
s
 
2347
select * from t2 where s = 'one';
 
2348
s
 
2349
select * from t3 where s = 'one';
 
2350
s
 
2351
one 
 
2352
select * from t1,t2 where t1.s = t2.s;
 
2353
s       s
 
2354
two             two     
 
2355
select * from t2,t3 where t2.s = t3.s;
 
2356
s       s
 
2357
two             two     
 
2358
drop table t1, t2, t3;
 
2359
create table t1 (a integer,  b integer, index(a), index(b));
 
2360
create table t2 (c integer,  d integer, index(c), index(d));
 
2361
insert into t1 values (1,2), (2,2), (3,2), (4,2);
 
2362
insert into t2 values (1,3), (2,3), (3,4), (4,4);
 
2363
explain select * from t1 left join t2 on a=c where d in (4);
 
2364
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
2365
1       SIMPLE  t2      ref     c,d     d       5       const   2       Using where
 
2366
1       SIMPLE  t1      ALL     a       NULL    NULL    NULL    4       Using where; Using join buffer
 
2367
select * from t1 left join t2 on a=c where d in (4);
 
2368
a       b       c       d
 
2369
3       2       3       4
 
2370
4       2       4       4
 
2371
explain select * from t1 left join t2 on a=c where d = 4;
 
2372
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
2373
1       SIMPLE  t2      ref     c,d     d       5       const   2       Using where
 
2374
1       SIMPLE  t1      ALL     a       NULL    NULL    NULL    4       Using where; Using join buffer
 
2375
select * from t1 left join t2 on a=c where d = 4;
 
2376
a       b       c       d
 
2377
3       2       3       4
 
2378
4       2       4       4
 
2379
drop table t1, t2;
 
2380
CREATE TABLE t1 (
 
2381
i int(11) NOT NULL default '0',
 
2382
c char(10) NOT NULL default '',
 
2383
PRIMARY KEY  (i),
 
2384
UNIQUE KEY c (c)
 
2385
) ENGINE=MyISAM;
 
2386
INSERT INTO t1 VALUES (1,'a');
 
2387
INSERT INTO t1 VALUES (2,'b');
 
2388
INSERT INTO t1 VALUES (3,'c');
 
2389
EXPLAIN SELECT i FROM t1 WHERE i=1;
 
2390
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
2391
1       SIMPLE  t1      const   PRIMARY PRIMARY 4       const   1       Using index
 
2392
DROP TABLE t1;
 
2393
CREATE TABLE t1 ( a BLOB, INDEX (a(20)) );
 
2394
CREATE TABLE t2 ( a BLOB, INDEX (a(20)) );
 
2395
INSERT INTO t1 VALUES ('one'),('two'),('three'),('four'),('five');
 
2396
INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five');
 
2397
EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USE INDEX (a) ON t1.a=t2.a;
 
2398
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
2399
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    5       
 
2400
1       SIMPLE  t2      ref     a       a       23      test.t1.a       2       
 
2401
EXPLAIN SELECT * FROM t1 LEFT JOIN t2 FORCE INDEX (a) ON t1.a=t2.a;
 
2402
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
2403
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    5       
 
2404
1       SIMPLE  t2      ref     a       a       23      test.t1.a       2       
 
2405
DROP TABLE t1, t2;
 
2406
CREATE TABLE t1 ( city char(30) );
 
2407
INSERT INTO t1 VALUES ('London');
 
2408
INSERT INTO t1 VALUES ('Paris');
 
2409
SELECT * FROM t1 WHERE city='London';
 
2410
city
 
2411
London
 
2412
SELECT * FROM t1 WHERE city='london';
 
2413
city
 
2414
London
 
2415
EXPLAIN SELECT * FROM t1 WHERE city='London' AND city='london';
 
2416
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
2417
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    2       Using where
 
2418
SELECT * FROM t1 WHERE city='London' AND city='london';
 
2419
city
 
2420
London
 
2421
EXPLAIN SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London';
 
2422
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
2423
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    2       Using where
 
2424
SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London';
 
2425
city
 
2426
London
 
2427
DROP TABLE t1;
 
2428
create table t1 (a int(11) unsigned, b int(11) unsigned);
 
2429
insert into t1 values (1,0), (1,1), (1,2);
 
2430
select a-b  from t1 order by 1;
 
2431
a-b
 
2432
0
 
2433
1
 
2434
18446744073709551615
 
2435
select a-b , (a-b < 0)  from t1 order by 1;
 
2436
a-b     (a-b < 0)
 
2437
0       0
 
2438
1       0
 
2439
18446744073709551615    0
 
2440
select a-b as d, (a-b >= 0), b from t1 group by b having d >= 0;
 
2441
d       (a-b >= 0)      b
 
2442
1       1       0
 
2443
0       1       1
 
2444
18446744073709551615    1       2
 
2445
select cast((a - b) as unsigned) from t1 order by 1;
 
2446
cast((a - b) as unsigned)
 
2447
0
 
2448
1
 
2449
18446744073709551615
 
2450
drop table t1;
 
2451
create table t1 (a int(11));
 
2452
select all all * from t1;
 
2453
a
 
2454
select distinct distinct * from t1;
 
2455
a
 
2456
select all distinct * from t1;
 
2457
ERROR HY000: Incorrect usage of ALL and DISTINCT
 
2458
select distinct all * from t1;
 
2459
ERROR HY000: Incorrect usage of ALL and DISTINCT
 
2460
drop table t1;
 
2461
CREATE TABLE t1 (
 
2462
kunde_intern_id int(10) unsigned NOT NULL default '0',
 
2463
kunde_id int(10) unsigned NOT NULL default '0',
 
2464
FK_firma_id int(10) unsigned NOT NULL default '0',
 
2465
aktuell enum('Ja','Nein') NOT NULL default 'Ja',
 
2466
vorname varchar(128) NOT NULL default '',
 
2467
nachname varchar(128) NOT NULL default '',
 
2468
geloescht enum('Ja','Nein') NOT NULL default 'Nein',
 
2469
firma varchar(128) NOT NULL default ''
 
2470
);
 
2471
INSERT INTO t1 VALUES 
 
2472
(3964,3051,1,'Ja','Vorname1','1Nachname','Nein','Print Schau XXXX'),
 
2473
(3965,3051111,1,'Ja','Vorname1111','1111Nachname','Nein','Print Schau XXXX');
 
2474
SELECT kunde_id ,FK_firma_id ,aktuell, vorname, nachname, geloescht FROM t1
 
2475
WHERE
 
2476
(
 
2477
(
 
2478
( '' != '' AND firma LIKE CONCAT('%', '', '%'))
 
2479
OR
 
2480
(vorname LIKE CONCAT('%', 'Vorname1', '%') AND 
 
2481
nachname LIKE CONCAT('%', '1Nachname', '%') AND 
 
2482
'Vorname1' != '' AND 'xxxx' != '')
 
2483
)
 
2484
AND
 
2485
(
 
2486
aktuell = 'Ja' AND geloescht = 'Nein' AND FK_firma_id = 2
 
2487
)
 
2488
)
 
2489
;
 
2490
kunde_id        FK_firma_id     aktuell vorname nachname        geloescht
 
2491
SELECT kunde_id ,FK_firma_id ,aktuell, vorname, nachname,
 
2492
geloescht FROM t1
 
2493
WHERE
 
2494
(
 
2495
(
 
2496
aktuell = 'Ja' AND geloescht = 'Nein' AND FK_firma_id = 2
 
2497
)
 
2498
AND
 
2499
(
 
2500
( '' != '' AND firma LIKE CONCAT('%', '', '%')  )
 
2501
OR
 
2502
(  vorname LIKE CONCAT('%', 'Vorname1', '%') AND
 
2503
nachname LIKE CONCAT('%', '1Nachname', '%') AND 'Vorname1' != '' AND
 
2504
'xxxx' != '')
 
2505
)
 
2506
)
 
2507
;
 
2508
kunde_id        FK_firma_id     aktuell vorname nachname        geloescht
 
2509
SELECT COUNT(*) FROM t1 WHERE 
 
2510
( 0 OR (vorname LIKE '%Vorname1%' AND nachname LIKE '%1Nachname%' AND 1)) 
 
2511
AND FK_firma_id = 2;
 
2512
COUNT(*)
 
2513
0
 
2514
drop table t1;
 
2515
CREATE TABLE t1 (b BIGINT(20) UNSIGNED NOT NULL, PRIMARY KEY (b));
 
2516
INSERT INTO t1 VALUES (0x8000000000000000);
 
2517
SELECT b FROM t1 WHERE b=0x8000000000000000;
 
2518
b
 
2519
9223372036854775808
 
2520
DROP TABLE t1;
 
2521
CREATE TABLE `t1` ( `gid` int(11) default NULL, `uid` int(11) default NULL);
 
2522
CREATE TABLE `t2` ( `ident` int(11) default NULL, `level` char(16) default NULL);
 
2523
INSERT INTO `t2` VALUES (0,'READ');
 
2524
CREATE TABLE `t3` ( `id` int(11) default NULL, `name` char(16) default NULL);
 
2525
INSERT INTO `t3` VALUES (1,'fs');
 
2526
select * from t3 left join t1 on t3.id = t1.uid, t2 where t2.ident in (0, t1.gid, t3.id, 0);
 
2527
id      name    gid     uid     ident   level
 
2528
1       fs      NULL    NULL    0       READ
 
2529
drop table t1,t2,t3;
 
2530
CREATE TABLE t1 (
 
2531
acct_id int(11) NOT NULL default '0',
 
2532
profile_id smallint(6) default NULL,
 
2533
UNIQUE KEY t1$acct_id (acct_id),
 
2534
KEY t1$profile_id (profile_id)
 
2535
);
 
2536
INSERT INTO t1 VALUES (132,17),(133,18);
 
2537
CREATE TABLE t2 (
 
2538
profile_id smallint(6) default NULL,
 
2539
queue_id int(11) default NULL,
 
2540
seq int(11) default NULL,
 
2541
KEY t2$queue_id (queue_id)
 
2542
);
 
2543
INSERT INTO t2 VALUES (17,31,4),(17,30,3),(17,36,2),(17,37,1);
 
2544
CREATE TABLE t3 (
 
2545
id int(11) NOT NULL default '0',
 
2546
qtype int(11) default NULL,
 
2547
seq int(11) default NULL,
 
2548
warn_lvl int(11) default NULL,
 
2549
crit_lvl int(11) default NULL,
 
2550
rr1 tinyint(4) NOT NULL default '0',
 
2551
rr2 int(11) default NULL,
 
2552
default_queue tinyint(4) NOT NULL default '0',
 
2553
KEY t3$qtype (qtype),
 
2554
KEY t3$id (id)
 
2555
);
 
2556
INSERT INTO t3 VALUES (30,1,29,NULL,NULL,0,NULL,0),(31,1,28,NULL,NULL,0,NULL,0),
 
2557
(36,1,34,NULL,NULL,0,NULL,0),(37,1,35,NULL,NULL,0,121,0);
 
2558
SELECT COUNT(*) FROM t1 a STRAIGHT_JOIN t2 pq STRAIGHT_JOIN t3 q 
 
2559
WHERE 
 
2560
(pq.profile_id = a.profile_id) AND (a.acct_id = 132) AND 
 
2561
(pq.queue_id = q.id) AND (q.rr1 <> 1);
 
2562
COUNT(*)
 
2563
4
 
2564
drop table t1,t2,t3;
 
2565
create table t1 (f1 int);
 
2566
insert into t1 values (1),(NULL);
 
2567
create table t2 (f2 int, f3 int, f4 int);
 
2568
create index idx1 on t2 (f4);
 
2569
insert into t2 values (1,2,3),(2,4,6);
 
2570
select A.f2 from t1 left join t2 A on A.f2 = f1 where A.f3=(select min(f3)
 
2571
from  t2 C where A.f4 = C.f4) or A.f3 IS NULL;
 
2572
f2
 
2573
1
 
2574
NULL
 
2575
drop table t1,t2;
 
2576
create table t2 (a tinyint unsigned);
 
2577
create index t2i on t2(a);
 
2578
insert into t2 values (0), (254), (255);
 
2579
explain select * from t2 where a > -1;
 
2580
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
2581
1       SIMPLE  t2      index   t2i     t2i     2       NULL    3       Using where; Using index
 
2582
select * from t2 where a > -1;
 
2583
a
 
2584
0
 
2585
254
 
2586
255
 
2587
drop table t2;
 
2588
CREATE TABLE t1 (a int, b int, c int);
 
2589
INSERT INTO t1
 
2590
SELECT 50, 3, 3 FROM DUAL
 
2591
WHERE NOT EXISTS
 
2592
(SELECT * FROM t1 WHERE a = 50 AND b = 3);
 
2593
SELECT * FROM t1;
 
2594
a       b       c
 
2595
50      3       3
 
2596
INSERT INTO t1
 
2597
SELECT 50, 3, 3 FROM DUAL
 
2598
WHERE NOT EXISTS
 
2599
(SELECT * FROM t1 WHERE a = 50 AND b = 3);
 
2600
select found_rows();
 
2601
found_rows()
 
2602
0
 
2603
SELECT * FROM t1;
 
2604
a       b       c
 
2605
50      3       3
 
2606
select count(*) from t1;
 
2607
count(*)
 
2608
1
 
2609
select found_rows();
 
2610
found_rows()
 
2611
1
 
2612
select count(*) from t1 limit 2,3;
 
2613
count(*)
 
2614
select found_rows();
 
2615
found_rows()
 
2616
0
 
2617
select SQL_CALC_FOUND_ROWS count(*) from t1 limit 2,3;
 
2618
count(*)
 
2619
select found_rows();
 
2620
found_rows()
 
2621
1
 
2622
DROP TABLE t1;
 
2623
CREATE TABLE t1 (a INT, b INT);
 
2624
(SELECT a, b AS c FROM t1) ORDER BY c+1;
 
2625
a       c
 
2626
(SELECT a, b AS c FROM t1) ORDER BY b+1;
 
2627
a       c
 
2628
SELECT a, b AS c FROM t1 ORDER BY c+1;
 
2629
a       c
 
2630
SELECT a, b AS c FROM t1 ORDER BY b+1;
 
2631
a       c
 
2632
drop table t1;
 
2633
create table t1(f1 int, f2 int);
 
2634
create table t2(f3 int);
 
2635
select f1 from t1,t2 where f1=f2 and (f1,f2) = ((1,1));
 
2636
f1
 
2637
select f1 from t1,t2 where f1=f2 and (f1,NULL) = ((1,1));
 
2638
f1
 
2639
select f1 from t1,t2 where f1=f2 and (f1,f2) = ((1,NULL));
 
2640
f1
 
2641
insert into t1 values(1,1),(2,null);
 
2642
insert into t2 values(2);
 
2643
select * from t1,t2 where f1=f3 and (f1,f2) = (2,null);
 
2644
f1      f2      f3
 
2645
select * from t1,t2 where f1=f3 and (f1,f2) <=> (2,null);
 
2646
f1      f2      f3
 
2647
2       NULL    2
 
2648
drop table t1,t2;
 
2649
create table t1 (f1 int not null auto_increment primary key, f2 varchar(10));
 
2650
create table t11 like t1;
 
2651
insert into t1 values(1,""),(2,"");
 
2652
show table status like 't1%';
 
2653
Name    Engine  Version Row_format      Rows    Avg_row_length  Data_length     Max_data_length Index_length    Data_free       Auto_increment  Create_time     Update_time     Check_time      Collation       Checksum        Create_options  Comment
 
2654
t1      MyISAM  10      Dynamic 2       20      X       X       X       X       X       X       X       X       latin1_swedish_ci       NULL            
 
2655
t11     MyISAM  10      Dynamic 0       0       X       X       X       X       X       X       X       X       latin1_swedish_ci       NULL            
 
2656
select 123 as a from t1 where f1 is null;
 
2657
a
 
2658
drop table t1,t11;
 
2659
CREATE TABLE t1 ( a INT NOT NULL, b INT NOT NULL, UNIQUE idx (a,b) );
 
2660
INSERT INTO t1 VALUES (1,1),(1,2),(1,3),(1,4);
 
2661
CREATE TABLE t2 ( a INT NOT NULL, b INT NOT NULL, e INT );
 
2662
INSERT INTO t2 VALUES ( 1,10,1), (1,10,2), (1,11,1), (1,11,2), (1,2,1), (1,2,2),(1,2,3);
 
2663
SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOIN
 
2664
t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY a, b, c;
 
2665
a       b       c       d
 
2666
1       2       1       1
 
2667
1       2       2       1
 
2668
1       2       3       1
 
2669
1       10              2
 
2670
1       11              2
 
2671
SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOIN
 
2672
t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY t1.a, t1.b, c;
 
2673
a       b       c       d
 
2674
1       10              4
 
2675
1       2       1       1
 
2676
1       2       2       1
 
2677
1       2       3       1
 
2678
SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOIN
 
2679
t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY t2.a, t2.b, c;
 
2680
a       b       c       d
 
2681
1       2       1       1
 
2682
1       2       2       1
 
2683
1       2       3       1
 
2684
1       10              2
 
2685
1       11              2
 
2686
SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2,t1
 
2687
WHERE t2.a = t1.a AND t2.b = t1.b GROUP BY a, b, c;
 
2688
a       b       c       d
 
2689
1       2       1       1
 
2690
1       2       2       1
 
2691
1       2       3       1
 
2692
DROP TABLE IF EXISTS t1, t2;
 
2693
create table t1 (f1 int primary key, f2 int);
 
2694
create table t2 (f3 int, f4 int, primary key(f3,f4));
 
2695
insert into t1 values (1,1);
 
2696
insert into t2 values (1,1),(1,2);
 
2697
select distinct count(f2) >0 from t1 left join t2 on f1=f3 group by f1;
 
2698
count(f2) >0
 
2699
1
 
2700
drop table t1,t2;
 
2701
create table t1 (f1 int,f2 int);
 
2702
insert into t1 values(1,1);
 
2703
create table t2 (f3 int, f4 int, primary key(f3,f4));
 
2704
insert into t2 values(1,1);
 
2705
select * from t1 where f1 in (select f3 from t2 where (f3,f4)= (select f3,f4 from t2));
 
2706
f1      f2
 
2707
1       1
 
2708
drop table t1,t2;
 
2709
CREATE TABLE t1(a int, b int, c int, KEY b(b), KEY c(c));
 
2710
insert into t1 values (1,0,0),(2,0,0);
 
2711
CREATE TABLE t2 (a int, b varchar(2), c varchar(2), PRIMARY KEY(a));
 
2712
insert into t2 values (1,'',''), (2,'','');
 
2713
CREATE TABLE t3 (a int, b int, PRIMARY KEY (a,b), KEY a (a), KEY b (b));
 
2714
insert into t3 values (1,1),(1,2);
 
2715
explain select straight_join DISTINCT t2.a,t2.b, t1.c from t1, t3, t2 
 
2716
where (t1.c=t2.a or (t1.c=t3.a and t2.a=t3.b)) and t1.b=556476786 and 
 
2717
t2.b like '%%' order by t2.b limit 0,1;
 
2718
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
2719
1       SIMPLE  t1      ref     b,c     b       5       const   1       Using where; Using temporary; Using filesort
 
2720
1       SIMPLE  t3      index   PRIMARY,a,b     PRIMARY 8       NULL    2       Using index; Using join buffer
 
2721
1       SIMPLE  t2      ALL     PRIMARY NULL    NULL    NULL    2       Range checked for each record (index map: 0x1)
 
2722
DROP TABLE t1,t2,t3;
 
2723
CREATE TABLE t1 (a int, INDEX idx(a));
 
2724
INSERT INTO t1 VALUES (2), (3), (1);
 
2725
EXPLAIN SELECT * FROM t1 IGNORE INDEX (idx);
 
2726
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
2727
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    3       
 
2728
EXPLAIN SELECT * FROM t1 IGNORE INDEX (a);
 
2729
ERROR 42000: Key 'a' doesn't exist in table 't1'
 
2730
EXPLAIN SELECT * FROM t1 FORCE INDEX (a);
 
2731
ERROR 42000: Key 'a' doesn't exist in table 't1'
 
2732
DROP TABLE t1;
 
2733
CREATE TABLE t1 (a int, b int);
 
2734
INSERT INTO t1 VALUES (1,1), (2,1), (4,10);
 
2735
CREATE TABLE t2 (a int PRIMARY KEY, b int, KEY b (b));
 
2736
INSERT INTO t2 VALUES (1,NULL), (2,10);
 
2737
ALTER TABLE t1 ENABLE KEYS;
 
2738
EXPLAIN SELECT STRAIGHT_JOIN SQL_NO_CACHE COUNT(*) FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL;
 
2739
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
2740
1       SIMPLE  t2      index   b       b       5       NULL    2       Using index
 
2741
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    3       Using where; Using join buffer
 
2742
SELECT STRAIGHT_JOIN SQL_NO_CACHE * FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL;
 
2743
a       b       a       b
 
2744
1       NULL    1       1
 
2745
1       NULL    2       1
 
2746
1       NULL    4       10
 
2747
2       10      4       10
 
2748
EXPLAIN SELECT STRAIGHT_JOIN SQL_NO_CACHE COUNT(*) FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL;
 
2749
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
2750
1       SIMPLE  t2      index   b       b       5       NULL    2       Using index
 
2751
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    3       Using where; Using join buffer
 
2752
SELECT STRAIGHT_JOIN SQL_NO_CACHE * FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL;
 
2753
a       b       a       b
 
2754
1       NULL    1       1
 
2755
1       NULL    2       1
 
2756
1       NULL    4       10
 
2757
2       10      4       10
 
2758
DROP TABLE IF EXISTS t1,t2;
 
2759
CREATE TABLE t1 (key1 float default NULL, UNIQUE KEY key1 (key1));
 
2760
CREATE TABLE t2 (key2 float default NULL, UNIQUE KEY key2 (key2));
 
2761
INSERT INTO t1 VALUES (0.3762),(0.3845),(0.6158),(0.7941);
 
2762
INSERT INTO t2 VALUES (1.3762),(1.3845),(1.6158),(1.7941);
 
2763
explain select max(key1) from t1 where key1 <= 0.6158;
 
2764
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
2765
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    Select tables optimized away
 
2766
explain select max(key2) from t2 where key2 <= 1.6158;
 
2767
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
2768
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    Select tables optimized away
 
2769
explain select min(key1) from t1 where key1 >= 0.3762;
 
2770
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
2771
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    Select tables optimized away
 
2772
explain select min(key2) from t2 where key2 >= 1.3762;
 
2773
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
2774
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    Select tables optimized away
 
2775
explain select max(key1), min(key2) from t1, t2
 
2776
where key1 <= 0.6158 and key2 >= 1.3762;
 
2777
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
2778
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    Select tables optimized away
 
2779
explain select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
 
2780
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
2781
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    Select tables optimized away
 
2782
explain select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
 
2783
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
2784
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    Select tables optimized away
 
2785
select max(key1) from t1 where key1 <= 0.6158;
 
2786
max(key1)
 
2787
0.615800023078918
 
2788
select max(key2) from t2 where key2 <= 1.6158;
 
2789
max(key2)
 
2790
1.61580002307892
 
2791
select min(key1) from t1 where key1 >= 0.3762;
 
2792
min(key1)
 
2793
0.376199990510941
 
2794
select min(key2) from t2 where key2 >= 1.3762;
 
2795
min(key2)
 
2796
1.37619996070862
 
2797
select max(key1), min(key2) from t1, t2
 
2798
where key1 <= 0.6158 and key2 >= 1.3762;
 
2799
max(key1)       min(key2)
 
2800
0.615800023078918       1.37619996070862
 
2801
select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
 
2802
max(key1)
 
2803
0.615800023078918
 
2804
select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
 
2805
min(key1)
 
2806
0.376199990510941
 
2807
DROP TABLE t1,t2;
 
2808
CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL);
 
2809
INSERT INTO t1 VALUES (10);
 
2810
SELECT i='1e+01',i=1e+01, i in (1e+01,1e+01), i in ('1e+01','1e+01') FROM t1;
 
2811
i='1e+01'       i=1e+01 i in (1e+01,1e+01)      i in ('1e+01','1e+01')
 
2812
1       1       1       1
 
2813
DROP TABLE t1;
 
2814
create table t1(a bigint unsigned, b bigint);
 
2815
insert into t1 values (0xfffffffffffffffff, 0xfffffffffffffffff), 
 
2816
(0x10000000000000000, 0x10000000000000000), 
 
2817
(0x8fffffffffffffff, 0x8fffffffffffffff);
 
2818
Warnings:
 
2819
Warning 1264    Out of range value for column 'a' at row 1
 
2820
Warning 1264    Out of range value for column 'b' at row 1
 
2821
Warning 1264    Out of range value for column 'a' at row 2
 
2822
Warning 1264    Out of range value for column 'b' at row 2
 
2823
Warning 1264    Out of range value for column 'b' at row 3
 
2824
select hex(a), hex(b) from t1;
 
2825
hex(a)  hex(b)
 
2826
FFFFFFFFFFFFFFFF        7FFFFFFFFFFFFFFF
 
2827
FFFFFFFFFFFFFFFF        7FFFFFFFFFFFFFFF
 
2828
8FFFFFFFFFFFFFFF        7FFFFFFFFFFFFFFF
 
2829
drop table t1;
 
2830
CREATE TABLE t1 (c0 int);
 
2831
CREATE TABLE t2 (c0 int);
 
2832
INSERT INTO t1 VALUES(@@connect_timeout);
 
2833
INSERT INTO t2 VALUES(@@connect_timeout);
 
2834
SELECT * FROM t1 JOIN t2 ON t1.c0 = t2.c0 WHERE (t1.c0 <=> @@connect_timeout);
 
2835
c0      c0
 
2836
X       X
 
2837
DROP TABLE t1, t2;
 
2838
End of 4.1 tests
 
2839
CREATE TABLE t1 ( 
 
2840
K2C4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '', 
 
2841
K4N4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '0000', 
 
2842
F2I4 int(11) NOT NULL default '0' 
 
2843
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
 
2844
INSERT INTO t1 VALUES 
 
2845
('W%RT', '0100',  1), 
 
2846
('W-RT', '0100', 1), 
 
2847
('WART', '0100', 1), 
 
2848
('WART', '0200', 1), 
 
2849
('WERT', '0100', 2), 
 
2850
('WORT','0200', 2), 
 
2851
('WT', '0100', 2), 
 
2852
('W_RT', '0100', 2), 
 
2853
('WaRT', '0100', 3), 
 
2854
('WART', '0300', 3), 
 
2855
('WRT' , '0400', 3), 
 
2856
('WURM', '0500', 3), 
 
2857
('W%T', '0600', 4), 
 
2858
('WA%T', '0700', 4), 
 
2859
('WA_T', '0800', 4);
 
2860
SELECT K2C4, K4N4, F2I4 FROM t1
 
2861
WHERE  K2C4 = 'WART' AND 
 
2862
(F2I4 = 2 AND K2C4 = 'WART' OR (F2I4 = 2 OR K4N4 = '0200'));
 
2863
K2C4    K4N4    F2I4
 
2864
WART    0200    1
 
2865
SELECT K2C4, K4N4, F2I4 FROM t1
 
2866
WHERE  K2C4 = 'WART' AND (K2C4 = 'WART' OR K4N4 = '0200');
 
2867
K2C4    K4N4    F2I4
 
2868
WART    0100    1
 
2869
WART    0200    1
 
2870
WART    0300    3
 
2871
DROP TABLE t1;
 
2872
create table t1 (a int, b int);
 
2873
create table t2 like t1;
 
2874
select t1.a from (t1 inner join t2 on t1.a=t2.a) where t2.a=1;
 
2875
a
 
2876
select t1.a from ((t1 inner join t2 on t1.a=t2.a)) where t2.a=1;
 
2877
a
 
2878
select x.a, y.a, z.a from ( (t1 x inner join t2 y on x.a=y.a) inner join t2 z on y.a=z.a) WHERE x.a=1;
 
2879
a       a       a
 
2880
drop table t1,t2;
 
2881
create table t1 (s1 varchar(5));
 
2882
insert into t1 values ('Wall');
 
2883
select min(s1) from t1 group by s1 with rollup;
 
2884
min(s1)
 
2885
Wall
 
2886
Wall
 
2887
drop table t1;
 
2888
create table t1 (s1 int) engine=myisam;
 
2889
insert into t1 values (0);
 
2890
select avg(distinct s1) from t1 group by s1 with rollup;
 
2891
avg(distinct s1)
 
2892
0.0000
 
2893
0.0000
 
2894
drop table t1;
 
2895
create table t1 (s1 int);
 
2896
insert into t1 values (null),(1);
 
2897
select distinct avg(s1) as x from t1 group by s1 with rollup;
 
2898
x
 
2899
NULL
 
2900
1.0000
 
2901
drop table t1;
 
2902
CREATE TABLE t1 (a int);
 
2903
CREATE TABLE t2 (a int);
 
2904
INSERT INTO t1 VALUES (1), (2), (3), (4), (5);
 
2905
INSERT INTO t2 VALUES (2), (4), (6);
 
2906
SELECT t1.a FROM t1 STRAIGHT_JOIN t2 ON t1.a=t2.a;
 
2907
a
 
2908
2
 
2909
4
 
2910
EXPLAIN SELECT t1.a FROM t1 STRAIGHT_JOIN t2 ON t1.a=t2.a;
 
2911
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
2912
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    5       
 
2913
1       SIMPLE  t2      ALL     NULL    NULL    NULL    NULL    3       Using where; Using join buffer
 
2914
EXPLAIN SELECT t1.a FROM t1 INNER JOIN t2 ON t1.a=t2.a;
 
2915
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
2916
1       SIMPLE  t2      ALL     NULL    NULL    NULL    NULL    3       
 
2917
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    5       Using where; Using join buffer
 
2918
DROP TABLE t1,t2;
 
2919
select x'10' + 0, X'10' + 0, b'10' + 0, B'10' + 0;
 
2920
x'10' + 0       X'10' + 0       b'10' + 0       B'10' + 0
 
2921
16      16      2       2
 
2922
create table t1 (f1 varchar(6) default NULL, f2 int(6) primary key not null);
 
2923
create table t2 (f3 varchar(5) not null, f4 varchar(5) not null, UNIQUE KEY UKEY (f3,f4));
 
2924
insert into t1 values (" 2", 2);
 
2925
insert into t2 values (" 2", " one "),(" 2", " two ");
 
2926
select * from t1 left join t2 on f1 = f3;
 
2927
f1      f2      f3      f4
 
2928
 2      2        2       one 
 
2929
 2      2        2       two 
 
2930
drop table t1,t2;
 
2931
create table t1 (empnum smallint, grp int);
 
2932
create table t2 (empnum int, name char(5));
 
2933
insert into t1 values(1,1);
 
2934
insert into t2 values(1,'bob');
 
2935
create view v1 as select * from t2 inner join t1 using (empnum);
 
2936
select * from v1;
 
2937
empnum  name    grp
 
2938
1       bob     1
 
2939
drop table t1,t2;
 
2940
drop view v1;
 
2941
create table t1 (pk int primary key, b int);
 
2942
create table t2 (pk int primary key, c int);
 
2943
select pk from t1 inner join t2 using (pk);
 
2944
pk
 
2945
drop table t1,t2;
 
2946
create table t1 (s1 int, s2 char(5), s3 decimal(10));
 
2947
create view v1 as select s1, s2, 'x' as s3 from t1;
 
2948
select * from t1 natural join v1;
 
2949
s1      s2      s3
 
2950
insert into t1 values (1,'x',5);
 
2951
select * from t1 natural join v1;
 
2952
s1      s2      s3
 
2953
Warnings:
 
2954
Warning 1292    Truncated incorrect DOUBLE value: 'x'
 
2955
drop table t1;
 
2956
drop view v1;
 
2957
create table t1(a1 int);
 
2958
create table t2(a2 int);
 
2959
insert into t1 values(1),(2);
 
2960
insert into t2 values(1),(2);
 
2961
create view v2 (c) as select a1 from t1;
 
2962
select * from t1 natural left join t2;
 
2963
a1      a2
 
2964
1       1
 
2965
1       2
 
2966
2       1
 
2967
2       2
 
2968
select * from t1 natural right join t2;
 
2969
a2      a1
 
2970
1       1
 
2971
1       2
 
2972
2       1
 
2973
2       2
 
2974
select * from v2 natural left join t2;
 
2975
c       a2
 
2976
1       1
 
2977
1       2
 
2978
2       1
 
2979
2       2
 
2980
select * from v2 natural right join t2;
 
2981
a2      c
 
2982
1       1
 
2983
1       2
 
2984
2       1
 
2985
2       2
 
2986
drop table t1, t2;
 
2987
drop view v2;
 
2988
create table t1 (a int(10), t1_val int(10));
 
2989
create table t2 (b int(10), t2_val int(10));
 
2990
create table t3 (a int(10), b int(10));
 
2991
insert into t1 values (1,1),(2,2);
 
2992
insert into t2 values (1,1),(2,2),(3,3);
 
2993
insert into t3 values (1,1),(2,1),(3,1),(4,1);
 
2994
select * from t1 natural join t2 natural join t3;
 
2995
a       b       t1_val  t2_val
 
2996
1       1       1       1
 
2997
2       1       2       1
 
2998
select * from t1 natural join t3 natural join t2;
 
2999
b       a       t1_val  t2_val
 
3000
1       1       1       1
 
3001
1       2       2       1
 
3002
drop table t1, t2, t3;
 
3003
DO IFNULL(NULL, NULL);
 
3004
SELECT CAST(IFNULL(NULL, NULL) AS DECIMAL);
 
3005
CAST(IFNULL(NULL, NULL) AS DECIMAL)
 
3006
NULL
 
3007
SELECT ABS(IFNULL(NULL, NULL));
 
3008
ABS(IFNULL(NULL, NULL))
 
3009
NULL
 
3010
SELECT IFNULL(NULL, NULL);
 
3011
IFNULL(NULL, NULL)
 
3012
NULL
 
3013
SET @OLD_SQL_MODE12595=@@SQL_MODE, @@SQL_MODE='';
 
3014
SHOW LOCAL VARIABLES LIKE 'SQL_MODE';
 
3015
Variable_name   Value
 
3016
sql_mode        
 
3017
CREATE TABLE BUG_12595(a varchar(100));
 
3018
INSERT INTO BUG_12595 VALUES ('hakan%'), ('hakank'), ("ha%an");
 
3019
SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%';
 
3020
a
 
3021
hakan%
 
3022
SELECT * FROM BUG_12595 WHERE a LIKE 'hakan*%' ESCAPE '*';
 
3023
a
 
3024
hakan%
 
3025
SELECT * FROM BUG_12595 WHERE a LIKE 'hakan**%' ESCAPE '**';
 
3026
ERROR HY000: Incorrect arguments to ESCAPE
 
3027
SELECT * FROM BUG_12595 WHERE a LIKE 'hakan%' ESCAPE '';
 
3028
a
 
3029
hakan%
 
3030
hakank
 
3031
SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%' ESCAPE '';
 
3032
a
 
3033
SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE 0x5c;
 
3034
a
 
3035
ha%an
 
3036
SELECT * FROM BUG_12595 WHERE a LIKE 'ha%%an' ESCAPE '%';
 
3037
a
 
3038
ha%an
 
3039
SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE '\\';
 
3040
a
 
3041
ha%an
 
3042
SELECT * FROM BUG_12595 WHERE a LIKE 'ha|%an' ESCAPE '|';
 
3043
a
 
3044
ha%an
 
3045
SET @@SQL_MODE='NO_BACKSLASH_ESCAPES';
 
3046
SHOW LOCAL VARIABLES LIKE 'SQL_MODE';
 
3047
Variable_name   Value
 
3048
sql_mode        NO_BACKSLASH_ESCAPES
 
3049
SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%';
 
3050
a
 
3051
SELECT * FROM BUG_12595 WHERE a LIKE 'hakan*%' ESCAPE '*';
 
3052
a
 
3053
hakan%
 
3054
SELECT * FROM BUG_12595 WHERE a LIKE 'hakan**%' ESCAPE '**';
 
3055
ERROR HY000: Incorrect arguments to ESCAPE
 
3056
SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%' ESCAPE '\\';
 
3057
ERROR HY000: Incorrect arguments to ESCAPE
 
3058
SELECT * FROM BUG_12595 WHERE a LIKE 'hakan%' ESCAPE '';
 
3059
ERROR HY000: Incorrect arguments to ESCAPE
 
3060
SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE 0x5c;
 
3061
a
 
3062
ha%an
 
3063
SELECT * FROM BUG_12595 WHERE a LIKE 'ha|%an' ESCAPE '|';
 
3064
a
 
3065
ha%an
 
3066
SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\n%' ESCAPE '\n';
 
3067
ERROR HY000: Incorrect arguments to ESCAPE
 
3068
SET @@SQL_MODE=@OLD_SQL_MODE12595;
 
3069
DROP TABLE BUG_12595;
 
3070
create table t1 (a char(1));
 
3071
create table t2 (a char(1));
 
3072
insert into t1 values ('a'),('b'),('c');
 
3073
insert into t2 values ('b'),('c'),('d');
 
3074
select a from t1 natural join t2;
 
3075
a
 
3076
b
 
3077
c
 
3078
select * from t1 natural join t2 where a = 'b';
 
3079
a
 
3080
b
 
3081
drop table t1, t2;
 
3082
CREATE TABLE t1 (`id` TINYINT);
 
3083
CREATE TABLE t2 (`id` TINYINT);
 
3084
CREATE TABLE t3 (`id` TINYINT);
 
3085
INSERT INTO t1 VALUES (1),(2),(3);
 
3086
INSERT INTO t2 VALUES (2);
 
3087
INSERT INTO t3 VALUES (3);
 
3088
SELECT t1.id,t3.id FROM t1 JOIN t2 ON (t2.id=t1.id) LEFT JOIN t3 USING (id);
 
3089
ERROR 23000: Column 'id' in from clause is ambiguous
 
3090
SELECT t1.id,t3.id FROM t1 JOIN t2 ON (t2.notacolumn=t1.id) LEFT JOIN t3 USING (id);
 
3091
ERROR 23000: Column 'id' in from clause is ambiguous
 
3092
SELECT id,t3.id FROM t1 JOIN t2 ON (t2.id=t1.id) LEFT JOIN t3 USING (id);
 
3093
ERROR 23000: Column 'id' in from clause is ambiguous
 
3094
SELECT id,t3.id FROM (t1 JOIN t2 ON (t2.id=t1.id)) LEFT JOIN t3 USING (id);
 
3095
ERROR 23000: Column 'id' in from clause is ambiguous
 
3096
drop table t1, t2, t3;
 
3097
create table t1 (a int(10),b int(10));
 
3098
create table t2 (a int(10),b int(10));
 
3099
insert into t1 values (1,10),(2,20),(3,30);
 
3100
insert into t2 values (1,10);
 
3101
select * from t1 inner join t2 using (A);
 
3102
a       b       b
 
3103
1       10      10
 
3104
select * from t1 inner join t2 using (a);
 
3105
a       b       b
 
3106
1       10      10
 
3107
drop table t1, t2;
 
3108
create table t1 (a int, c int);
 
3109
create table t2 (b int);
 
3110
create table t3 (b int, a int);
 
3111
create table t4 (c int);
 
3112
insert into t1 values (1,1);
 
3113
insert into t2 values (1);
 
3114
insert into t3 values (1,1);
 
3115
insert into t4 values (1);
 
3116
select * from t1 join t2 join t3 on (t2.b = t3.b and t1.a = t3.a);
 
3117
a       c       b       b       a
 
3118
1       1       1       1       1
 
3119
select * from t1, t2 join t3 on (t2.b = t3.b and t1.a = t3.a);
 
3120
ERROR 42S22: Unknown column 't1.a' in 'on clause'
 
3121
select * from t1 join t2 join t3 join t4 on (t1.a = t4.c and t2.b = t4.c);
 
3122
a       c       b       b       a       c
 
3123
1       1       1       1       1       1
 
3124
select * from t1 join t2 join t4 using (c);
 
3125
c       a       b
 
3126
1       1       1
 
3127
drop table t1, t2, t3, t4;
 
3128
create table t1(x int, y int);
 
3129
create table t2(x int, y int);
 
3130
create table t3(x int, primary key(x));
 
3131
insert into t1 values (1, 1), (2, 1), (3, 1), (4, 3), (5, 6), (6, 6);
 
3132
insert into t2 values (1, 1), (2, 1), (3, 3), (4, 6), (5, 6);
 
3133
insert into t3 values (1), (2), (3), (4), (5);
 
3134
select t1.x, t3.x from t1, t2, t3  where t1.x = t2.x and t3.x >= t1.y and t3.x <= t2.y;
 
3135
x       x
 
3136
1       1
 
3137
2       1
 
3138
3       1
 
3139
3       2
 
3140
3       3
 
3141
4       3
 
3142
4       4
 
3143
4       5
 
3144
drop table t1,t2,t3;
 
3145
create table t1 (id char(16) not null default '', primary key  (id));
 
3146
insert into t1 values ('100'),('101'),('102');
 
3147
create table t2 (id char(16) default null);
 
3148
insert into t2 values (1);
 
3149
create view v1 as select t1.id from t1;
 
3150
create view v2 as select t2.id from t2;
 
3151
create view v3 as select (t1.id+2) as id from t1 natural left join t2;
 
3152
select t1.id from t1 left join v2 using (id);
 
3153
id
 
3154
100
 
3155
101
 
3156
102
 
3157
select t1.id from v2 right join t1 using (id);
 
3158
id
 
3159
100
 
3160
101
 
3161
102
 
3162
select t1.id from t1 left join v3 using (id);
 
3163
id
 
3164
100
 
3165
101
 
3166
102
 
3167
select * from t1 left join v2 using (id);
 
3168
id
 
3169
100
 
3170
101
 
3171
102
 
3172
select * from v2 right join t1 using (id);
 
3173
id
 
3174
100
 
3175
101
 
3176
102
 
3177
select * from t1 left join v3 using (id);
 
3178
id
 
3179
100
 
3180
101
 
3181
102
 
3182
select v1.id from v1 left join v2 using (id);
 
3183
id
 
3184
100
 
3185
101
 
3186
102
 
3187
select v1.id from v2 right join v1 using (id);
 
3188
id
 
3189
100
 
3190
101
 
3191
102
 
3192
select v1.id from v1 left join v3 using (id);
 
3193
id
 
3194
100
 
3195
101
 
3196
102
 
3197
select * from v1 left join v2 using (id);
 
3198
id
 
3199
100
 
3200
101
 
3201
102
 
3202
select * from v2 right join v1 using (id);
 
3203
id
 
3204
100
 
3205
101
 
3206
102
 
3207
select * from v1 left join v3 using (id);
 
3208
id
 
3209
100
 
3210
101
 
3211
102
 
3212
drop table t1, t2;
 
3213
drop view v1, v2, v3;
 
3214
create table t1 (id int(11) not null default '0');
 
3215
insert into t1 values (123),(191),(192);
 
3216
create table t2 (id char(16) character set utf8 not null);
 
3217
insert into t2 values ('58013'),('58014'),('58015'),('58016');
 
3218
create table t3 (a_id int(11) not null, b_id char(16) character set utf8);
 
3219
insert into t3 values (123,null),(123,null),(123,null),(123,null),(123,null),(123,'58013');
 
3220
select count(*)
 
3221
from t1 inner join (t3 left join t2 on t2.id = t3.b_id) on t1.id = t3.a_id;
 
3222
count(*)
 
3223
6
 
3224
select count(*)
 
3225
from t1 inner join (t2 right join t3 on t2.id = t3.b_id) on t1.id = t3.a_id;
 
3226
count(*)
 
3227
6
 
3228
drop table t1,t2,t3;
 
3229
create table t1 (a int);
 
3230
create table t2 (b int);
 
3231
create table t3 (c int);
 
3232
select * from t1 join t2 join t3 on (t1.a=t3.c);
 
3233
a       b       c
 
3234
select * from t1 join t2 left join t3 on (t1.a=t3.c);
 
3235
a       b       c
 
3236
select * from t1 join t2 right join t3 on (t1.a=t3.c);
 
3237
a       b       c
 
3238
select * from t1 join t2 straight_join t3 on (t1.a=t3.c);
 
3239
a       b       c
 
3240
drop table t1, t2 ,t3;
 
3241
create table t1(f1 int, f2 date);
 
3242
insert into t1 values(1,'2005-01-01'),(2,'2005-09-01'),(3,'2005-09-30'),
 
3243
(4,'2005-10-01'),(5,'2005-12-30');
 
3244
select * from t1 where f2 >= 0            order by f2;
 
3245
f1      f2
 
3246
1       2005-01-01
 
3247
2       2005-09-01
 
3248
3       2005-09-30
 
3249
4       2005-10-01
 
3250
5       2005-12-30
 
3251
select * from t1 where f2 >= '0000-00-00' order by f2;
 
3252
f1      f2
 
3253
1       2005-01-01
 
3254
2       2005-09-01
 
3255
3       2005-09-30
 
3256
4       2005-10-01
 
3257
5       2005-12-30
 
3258
select * from t1 where f2 >= '2005-09-31' order by f2;
 
3259
f1      f2
 
3260
4       2005-10-01
 
3261
5       2005-12-30
 
3262
select * from t1 where f2 >= '2005-09-3a' order by f2;
 
3263
f1      f2
 
3264
3       2005-09-30
 
3265
4       2005-10-01
 
3266
5       2005-12-30
 
3267
Warnings:
 
3268
Warning 1292    Incorrect date value: '2005-09-3a' for column 'f2' at row 1
 
3269
select * from t1 where f2 <= '2005-09-31' order by f2;
 
3270
f1      f2
 
3271
1       2005-01-01
 
3272
2       2005-09-01
 
3273
3       2005-09-30
 
3274
select * from t1 where f2 <= '2005-09-3a' order by f2;
 
3275
f1      f2
 
3276
1       2005-01-01
 
3277
2       2005-09-01
 
3278
Warnings:
 
3279
Warning 1292    Incorrect date value: '2005-09-3a' for column 'f2' at row 1
 
3280
drop table t1;
 
3281
create table t1 (f1 int, f2 int);
 
3282
insert into t1 values (1, 30), (2, 20), (3, 10);
 
3283
create algorithm=merge view v1 as select f1, f2 from t1;
 
3284
create algorithm=merge view v2 (f2, f1) as select f1, f2 from t1;
 
3285
create algorithm=merge view v3 as select t1.f1 as f2, t1.f2 as f1 from t1;
 
3286
select t1.f1 as x1, f1 from t1 order by t1.f1;
 
3287
x1      f1
 
3288
1       1
 
3289
2       2
 
3290
3       3
 
3291
select v1.f1 as x1, f1 from v1 order by v1.f1;
 
3292
x1      f1
 
3293
1       1
 
3294
2       2
 
3295
3       3
 
3296
select v2.f1 as x1, f1 from v2 order by v2.f1;
 
3297
x1      f1
 
3298
10      10
 
3299
20      20
 
3300
30      30
 
3301
select v3.f1 as x1, f1 from v3 order by v3.f1;
 
3302
x1      f1
 
3303
10      10
 
3304
20      20
 
3305
30      30
 
3306
select f1, f2, v1.f1 as x1 from v1 order by v1.f1;
 
3307
f1      f2      x1
 
3308
1       30      1
 
3309
2       20      2
 
3310
3       10      3
 
3311
select f1, f2, v2.f1 as x1 from v2 order by v2.f1;
 
3312
f1      f2      x1
 
3313
10      3       10
 
3314
20      2       20
 
3315
30      1       30
 
3316
select f1, f2, v3.f1 as x1 from v3 order by v3.f1;
 
3317
f1      f2      x1
 
3318
10      3       10
 
3319
20      2       20
 
3320
30      1       30
 
3321
drop table t1;
 
3322
drop view v1, v2, v3;
 
3323
CREATE TABLE t1(key_a int4 NOT NULL, optimus varchar(32), PRIMARY KEY(key_a));
 
3324
CREATE TABLE t2(key_a int4 NOT NULL, prime varchar(32), PRIMARY KEY(key_a));
 
3325
CREATE table t3(key_a int4 NOT NULL, key_b int4 NOT NULL, foo varchar(32),
 
3326
PRIMARY KEY(key_a,key_b));
 
3327
INSERT INTO t1 VALUES (0,'');
 
3328
INSERT INTO t1 VALUES (1,'i');
 
3329
INSERT INTO t1 VALUES (2,'j');
 
3330
INSERT INTO t1 VALUES (3,'k');
 
3331
INSERT INTO t2 VALUES (1,'r');
 
3332
INSERT INTO t2 VALUES (2,'s');
 
3333
INSERT INTO t2 VALUES (3,'t');
 
3334
INSERT INTO t3 VALUES (1,5,'x');
 
3335
INSERT INTO t3 VALUES (1,6,'y');
 
3336
INSERT INTO t3 VALUES (2,5,'xx');
 
3337
INSERT INTO t3 VALUES (2,6,'yy');
 
3338
INSERT INTO t3 VALUES (2,7,'zz');
 
3339
INSERT INTO t3 VALUES (3,5,'xxx');
 
3340
SELECT t2.key_a,foo 
 
3341
FROM t1 INNER JOIN t2 ON t1.key_a = t2.key_a
 
3342
INNER JOIN t3 ON t1.key_a = t3.key_a
 
3343
WHERE t2.key_a=2 and key_b=5;
 
3344
key_a   foo
 
3345
2       xx
 
3346
EXPLAIN SELECT t2.key_a,foo 
 
3347
FROM t1 INNER JOIN t2 ON t1.key_a = t2.key_a
 
3348
INNER JOIN t3 ON t1.key_a = t3.key_a
 
3349
WHERE t2.key_a=2 and key_b=5;
 
3350
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
3351
1       SIMPLE  t1      const   PRIMARY PRIMARY 4       const   1       Using index
 
3352
1       SIMPLE  t2      const   PRIMARY PRIMARY 4       const   1       Using index
 
3353
1       SIMPLE  t3      const   PRIMARY PRIMARY 8       const,const     1       
 
3354
SELECT t2.key_a,foo 
 
3355
FROM t1 INNER JOIN t2 ON t2.key_a = t1.key_a
 
3356
INNER JOIN t3 ON t1.key_a = t3.key_a
 
3357
WHERE t2.key_a=2 and key_b=5;
 
3358
key_a   foo
 
3359
2       xx
 
3360
EXPLAIN SELECT t2.key_a,foo 
 
3361
FROM t1 INNER JOIN t2 ON t2.key_a = t1.key_a
 
3362
INNER JOIN t3 ON t1.key_a = t3.key_a
 
3363
WHERE t2.key_a=2 and key_b=5;
 
3364
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
3365
1       SIMPLE  t1      const   PRIMARY PRIMARY 4       const   1       Using index
 
3366
1       SIMPLE  t2      const   PRIMARY PRIMARY 4       const   1       Using index
 
3367
1       SIMPLE  t3      const   PRIMARY PRIMARY 8       const,const     1       
 
3368
DROP TABLE t1,t2,t3;
 
3369
create  table t1 (f1 int);
 
3370
insert into t1 values(1),(2);
 
3371
create table t2 (f2 int, f3 int, key(f2));
 
3372
insert into t2 values(1,1),(2,2);
 
3373
create table t3 (f4 int not null);
 
3374
insert into t3 values (2),(2),(2);
 
3375
select f1,(select count(*) from t2,t3 where f2=f1 and f3=f4) as count from t1;
 
3376
f1      count
 
3377
1       0
 
3378
2       3
 
3379
drop table t1,t2,t3;
 
3380
create table t1 (f1 int unique);
 
3381
create table t2 (f2 int unique);
 
3382
create table t3 (f3 int unique);
 
3383
insert into t1 values(1),(2);
 
3384
insert into t2 values(1),(2);
 
3385
insert into t3 values(1),(NULL);
 
3386
select * from t3 where f3 is null;
 
3387
f3
 
3388
NULL
 
3389
select t2.f2 from t1 left join t2 on f1=f2 join t3 on f1=f3 where f1=1;
 
3390
f2
 
3391
1
 
3392
drop table t1,t2,t3;
 
3393
create table t1(f1 char, f2 char not null);
 
3394
insert into t1 values(null,'a');
 
3395
create table t2 (f2 char not null);
 
3396
insert into t2 values('b');
 
3397
select * from t1 left join t2 on f1=t2.f2 where t1.f2='a';
 
3398
f1      f2      f2
 
3399
NULL    a       NULL
 
3400
drop table t1,t2;
 
3401
select * from (select * left join t on f1=f2) tt;
 
3402
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 'on f1=f2) tt' at line 1
 
3403
CREATE TABLE t1 (sku int PRIMARY KEY, pr int);
 
3404
CREATE TABLE t2 (sku int PRIMARY KEY, sppr int, name varchar(255));
 
3405
INSERT INTO t1 VALUES
 
3406
(10, 10), (20, 10), (30, 20), (40, 30), (50, 10), (60, 10);
 
3407
INSERT INTO t2 VALUES 
 
3408
(10, 10, 'aaa'), (20, 10, 'bbb'), (30, 10, 'ccc'), (40, 20, 'ddd'),
 
3409
(50, 10, 'eee'), (60, 20, 'fff'), (70, 20, 'ggg'), (80, 30, 'hhh');
 
3410
SELECT t2.sku, t2.sppr, t2.name, t1.sku, t1.pr
 
3411
FROM t2, t1 WHERE t2.sku=20 AND (t2.sku=t1.sku OR t2.sppr=t1.sku);
 
3412
sku     sppr    name    sku     pr
 
3413
20      10      bbb     10      10
 
3414
20      10      bbb     20      10
 
3415
EXPLAIN
 
3416
SELECT t2.sku, t2.sppr, t2.name, t1.sku, t1.pr
 
3417
FROM t2, t1 WHERE t2.sku=20 AND (t2.sku=t1.sku OR t2.sppr=t1.sku);
 
3418
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
3419
1       SIMPLE  t2      const   PRIMARY PRIMARY 4       const   1       
 
3420
1       SIMPLE  t1      range   PRIMARY PRIMARY 4       NULL    2       Using where
 
3421
DROP TABLE t1,t2;
 
3422
CREATE TABLE t1 (i TINYINT UNSIGNED NOT NULL);
 
3423
INSERT t1 SET i = 0;
 
3424
UPDATE t1 SET i = -1;
 
3425
Warnings:
 
3426
Warning 1264    Out of range value for column 'i' at row 1
 
3427
SELECT * FROM t1;
 
3428
i
 
3429
0
 
3430
UPDATE t1 SET i = CAST(i - 1 AS SIGNED);
 
3431
Warnings:
 
3432
Warning 1264    Out of range value for column 'i' at row 1
 
3433
SELECT * FROM t1;
 
3434
i
 
3435
0
 
3436
UPDATE t1 SET i = i - 1;
 
3437
Warnings:
 
3438
Warning 1264    Out of range value for column 'i' at row 1
 
3439
SELECT * FROM t1;
 
3440
i
 
3441
255
 
3442
DROP TABLE t1;
 
3443
create table t1 (a int);
 
3444
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
 
3445
create table t2 (a int, b int, c int, e int, primary key(a,b,c));
 
3446
insert into t2 select A.a, B.a, C.a, C.a from t1 A, t1 B, t1 C;
 
3447
analyze table t2;
 
3448
Table   Op      Msg_type        Msg_text
 
3449
test.t2 analyze status  OK
 
3450
select 'In next EXPLAIN, B.rows must be exactly 10:' Z;
 
3451
Z
 
3452
In next EXPLAIN, B.rows must be exactly 10:
 
3453
explain select * from t2 A, t2 B where A.a=5 and A.b=5 and A.C<5
 
3454
and B.a=5 and B.b=A.e and (B.b =1 or B.b = 3 or B.b=5);
 
3455
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
3456
1       SIMPLE  A       range   PRIMARY PRIMARY 12      NULL    4       Using where
 
3457
1       SIMPLE  B       ref     PRIMARY PRIMARY 8       const,test.A.e  10      
 
3458
drop table t1, t2;
 
3459
CREATE TABLE t1 (a int PRIMARY KEY, b int, INDEX(b));
 
3460
INSERT INTO t1 VALUES (1, 3), (9,4), (7,5), (4,5), (6,2),
 
3461
(3,1), (5,1), (8,9), (2,2), (0,9);
 
3462
CREATE TABLE t2 (c int, d int, f int, INDEX(c,f));
 
3463
INSERT INTO t2 VALUES
 
3464
(1,0,0), (1,0,1), (2,0,0), (2,0,1), (3,0,0), (4,0,1),
 
3465
(5,0,0), (5,0,1), (6,0,0), (0,0,1), (7,0,0), (7,0,1),
 
3466
(0,0,0), (0,0,1), (8,0,0), (8,0,1), (9,0,0), (9,0,1);
 
3467
EXPLAIN
 
3468
SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6;
 
3469
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
3470
1       SIMPLE  t1      range   PRIMARY,b       b       5       NULL    3       Using where
 
3471
1       SIMPLE  t2      ref     c       c       5       test.t1.a       2       Using where
 
3472
EXPLAIN
 
3473
SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6 AND a > 0;
 
3474
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
3475
1       SIMPLE  t1      range   PRIMARY,b       b       5       NULL    3       Using where
 
3476
1       SIMPLE  t2      ref     c       c       5       test.t1.a       2       Using where
 
3477
DROP TABLE t1, t2;
 
3478
create table t1 (
 
3479
a int unsigned    not null auto_increment primary key,
 
3480
b bit             not null,
 
3481
c bit             not null
 
3482
);
 
3483
create table t2 (
 
3484
a int unsigned    not null auto_increment primary key,
 
3485
b bit             not null,
 
3486
c int unsigned    not null,
 
3487
d varchar(50)
 
3488
);
 
3489
insert into t1 (b,c) values (0,1), (0,1);
 
3490
insert into t2 (b,c) values (0,1);
 
3491
select t1.a, t1.b + 0, t1.c + 0, t2.a, t2.b + 0, t2.c, t2.d
 
3492
from t1 left outer join t2 on t1.a = t2.c and t2.b <> 1
 
3493
where t1.b <> 1 order by t1.a;
 
3494
a       t1.b + 0        t1.c + 0        a       t2.b + 0        c       d
 
3495
1       0       1       1       0       1       NULL
 
3496
2       0       1       NULL    NULL    NULL    NULL
 
3497
drop table t1,t2;
 
3498
SELECT 0.9888889889 * 1.011111411911;
 
3499
0.9888889889 * 1.011111411911
 
3500
0.9998769417899202067879
 
3501
prepare stmt from 'select 1 as " a "';
 
3502
Warnings:
 
3503
Warning 1466    Leading spaces are removed from name ' a '
 
3504
execute stmt;
 
3505
 
3506
1
 
3507
CREATE TABLE t1 (a int NOT NULL PRIMARY KEY, b int NOT NULL);
 
3508
INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4);
 
3509
CREATE TABLE t2 (c int NOT NULL, INDEX idx(c));
 
3510
INSERT INTO t2 VALUES
 
3511
(1), (1), (1), (1), (1), (1), (1), (1),
 
3512
(2), (2), (2), (2),
 
3513
(3), (3),
 
3514
(4);
 
3515
EXPLAIN SELECT b FROM t1, t2 WHERE b=c AND a=1;
 
3516
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
3517
1       SIMPLE  t1      const   PRIMARY PRIMARY 4       const   1       
 
3518
1       SIMPLE  t2      ref     idx     idx     4       const   7       Using index
 
3519
EXPLAIN SELECT b FROM t1, t2 WHERE b=c AND a=4;
 
3520
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
3521
1       SIMPLE  t1      const   PRIMARY PRIMARY 4       const   1       
 
3522
1       SIMPLE  t2      ref     idx     idx     4       const   1       Using index
 
3523
DROP TABLE t1, t2;
 
3524
CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, a int);
 
3525
INSERT INTO t1 VALUES (1,2), (2,NULL), (3,2);
 
3526
CREATE TABLE t2 (b int, c INT, INDEX idx1(b));
 
3527
INSERT INTO t2 VALUES (2,1), (3,2);
 
3528
CREATE TABLE t3 (d int,  e int, INDEX idx1(d));
 
3529
INSERT INTO t3 VALUES (2,10), (2,20), (1,30), (2,40), (2,50);
 
3530
EXPLAIN
 
3531
SELECT * FROM t1 LEFT JOIN t2 ON t2.b=t1.a INNER JOIN t3 ON t3.d=t1.id
 
3532
WHERE t1.id=2;
 
3533
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
3534
1       SIMPLE  t1      const   PRIMARY PRIMARY 4       const   1       
 
3535
1       SIMPLE  t2      const   idx1    NULL    NULL    NULL    1       
 
3536
1       SIMPLE  t3      ref     idx1    idx1    5       const   3       Using where
 
3537
SELECT * FROM t1 LEFT JOIN t2 ON t2.b=t1.a INNER JOIN t3 ON t3.d=t1.id
 
3538
WHERE t1.id=2;
 
3539
id      a       b       c       d       e
 
3540
2       NULL    NULL    NULL    2       10
 
3541
2       NULL    NULL    NULL    2       20
 
3542
2       NULL    NULL    NULL    2       40
 
3543
2       NULL    NULL    NULL    2       50
 
3544
DROP TABLE t1,t2,t3;
 
3545
create table t1 (c1 varchar(1), c2 int, c3 int, c4 int, c5 int, c6 int,
 
3546
c7 int, c8 int, c9 int, fulltext key (`c1`));
 
3547
select distinct match (`c1`) against ('z') , c2, c3, c4,c5, c6,c7, c8 
 
3548
from t1 where c9=1 order by c2, c2;
 
3549
match (`c1`) against ('z')      c2      c3      c4      c5      c6      c7      c8
 
3550
drop table t1;
 
3551
CREATE TABLE t1 (pk varchar(10) PRIMARY KEY, fk varchar(16));
 
3552
CREATE TABLE t2 (pk varchar(16) PRIMARY KEY, fk varchar(10));
 
3553
INSERT INTO t1 VALUES
 
3554
('d','dddd'), ('i','iii'), ('a','aa'), ('b','bb'), ('g','gg'), 
 
3555
('e','eee'), ('c','cccc'), ('h','hhh'), ('j','jjj'), ('f','fff');
 
3556
INSERT INTO t2 VALUES
 
3557
('jjj', 'j'), ('cc','c'), ('ccc','c'), ('aaa', 'a'), ('jjjj','j'),
 
3558
('hhh','h'), ('gg','g'), ('fff','f'), ('ee','e'), ('ffff','f'),
 
3559
('bbb','b'), ('ff','f'), ('cccc','c'), ('dddd','d'), ('jj','j'),
 
3560
('aaaa','a'), ('bb','b'), ('eeee','e'), ('aa','a'), ('hh','h');
 
3561
EXPLAIN SELECT t2.* 
 
3562
FROM t1 JOIN t2 ON t2.fk=t1.pk
 
3563
WHERE t2.fk < 'c' AND t2.pk=t1.fk;
 
3564
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
3565
1       SIMPLE  t1      range   PRIMARY PRIMARY 12      NULL    3       Using where
 
3566
1       SIMPLE  t2      eq_ref  PRIMARY PRIMARY 18      test.t1.fk      1       Using where
 
3567
EXPLAIN SELECT t2.* 
 
3568
FROM t1 JOIN t2 ON t2.fk=t1.pk 
 
3569
WHERE t2.fk BETWEEN 'a' AND 'b' AND t2.pk=t1.fk;
 
3570
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
3571
1       SIMPLE  t1      range   PRIMARY PRIMARY 12      NULL    2       Using where
 
3572
1       SIMPLE  t2      eq_ref  PRIMARY PRIMARY 18      test.t1.fk      1       Using where
 
3573
EXPLAIN SELECT t2.* 
 
3574
FROM t1 JOIN t2 ON t2.fk=t1.pk 
 
3575
WHERE t2.fk IN ('a','b') AND t2.pk=t1.fk;
 
3576
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
3577
1       SIMPLE  t1      range   PRIMARY PRIMARY 12      NULL    2       Using where
 
3578
1       SIMPLE  t2      eq_ref  PRIMARY PRIMARY 18      test.t1.fk      1       Using where
 
3579
DROP TABLE t1,t2;
 
3580
CREATE TABLE t1 (a int, b varchar(20) NOT NULL, PRIMARY KEY(a));
 
3581
CREATE TABLE t2 (a int, b varchar(20) NOT NULL,
 
3582
PRIMARY KEY (a), UNIQUE KEY (b));
 
3583
INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c');
 
3584
INSERT INTO t2 VALUES (1,'a'),(2,'b'),(3,'c');
 
3585
EXPLAIN SELECT t1.a FROM t1 LEFT JOIN t2 ON t2.b=t1.b WHERE t1.a=3;
 
3586
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
3587
1       SIMPLE  t1      const   PRIMARY PRIMARY 4       const   1       
 
3588
1       SIMPLE  t2      const   b       b       22      const   1       Using index
 
3589
DROP TABLE t1,t2;
 
3590
CREATE TABLE t1(id int PRIMARY KEY, b int, e int);
 
3591
CREATE TABLE t2(i int, a int, INDEX si(i), INDEX ai(a));
 
3592
CREATE TABLE t3(a int PRIMARY KEY, c char(4), INDEX ci(c));
 
3593
INSERT INTO t1 VALUES 
 
3594
(1,10,19), (2,20,22), (4,41,42), (9,93,95), (7, 77,79),
 
3595
(6,63,67), (5,55,58), (3,38,39), (8,81,89);
 
3596
INSERT INTO t2 VALUES
 
3597
(21,210), (41,410), (82,820), (83,830), (84,840),
 
3598
(65,650), (51,510), (37,370), (94,940), (76,760),
 
3599
(22,220), (33,330), (40,400), (95,950), (38,380),
 
3600
(67,670), (88,880), (57,570), (96,960), (97,970);
 
3601
INSERT INTO t3 VALUES
 
3602
(210,'bb'), (950,'ii'), (400,'ab'), (500,'ee'), (220,'gg'),
 
3603
(440,'gg'), (310,'eg'), (380,'ee'), (840,'bb'), (830,'ff'),
 
3604
(230,'aa'), (960,'ii'), (410,'aa'), (510,'ee'), (290,'bb'),
 
3605
(450,'gg'), (320,'dd'), (390,'hh'), (850,'jj'), (860,'ff');
 
3606
EXPLAIN
 
3607
SELECT t3.a FROM t1,t2 FORCE INDEX (si),t3
 
3608
WHERE t1.id = 8 AND t2.i BETWEEN t1.b AND t1.e AND 
 
3609
t3.a=t2.a AND t3.c IN ('bb','ee');
 
3610
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
3611
1       SIMPLE  t1      const   PRIMARY PRIMARY 4       const   1       
 
3612
1       SIMPLE  t2      range   si      si      5       NULL    4       Using where
 
3613
1       SIMPLE  t3      eq_ref  PRIMARY,ci      PRIMARY 4       test.t2.a       1       Using where
 
3614
EXPLAIN
 
3615
SELECT t3.a FROM t1,t2,t3
 
3616
WHERE t1.id = 8 AND t2.i BETWEEN t1.b AND t1.e AND
 
3617
t3.a=t2.a AND t3.c IN ('bb','ee') ;
 
3618
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
3619
1       SIMPLE  t1      const   PRIMARY PRIMARY 4       const   1       
 
3620
1       SIMPLE  t2      range   si,ai   si      5       NULL    4       Using where
 
3621
1       SIMPLE  t3      eq_ref  PRIMARY,ci      PRIMARY 4       test.t2.a       1       Using where
 
3622
EXPLAIN 
 
3623
SELECT t3.a FROM t1,t2 FORCE INDEX (si),t3
 
3624
WHERE t1.id = 8 AND (t2.i=t1.b OR t2.i=t1.e) AND t3.a=t2.a AND
 
3625
t3.c IN ('bb','ee');
 
3626
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
3627
1       SIMPLE  t1      const   PRIMARY PRIMARY 4       const   1       
 
3628
1       SIMPLE  t2      range   si      si      5       NULL    2       Using where
 
3629
1       SIMPLE  t3      eq_ref  PRIMARY,ci      PRIMARY 4       test.t2.a       1       Using where
 
3630
EXPLAIN 
 
3631
SELECT t3.a FROM t1,t2,t3
 
3632
WHERE t1.id = 8 AND (t2.i=t1.b OR t2.i=t1.e) AND t3.a=t2.a AND
 
3633
t3.c IN ('bb','ee');
 
3634
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
3635
1       SIMPLE  t1      const   PRIMARY PRIMARY 4       const   1       
 
3636
1       SIMPLE  t2      range   si,ai   si      5       NULL    2       Using where
 
3637
1       SIMPLE  t3      eq_ref  PRIMARY,ci      PRIMARY 4       test.t2.a       1       Using where
 
3638
DROP TABLE t1,t2,t3;
 
3639
CREATE TABLE t1 ( f1 int primary key, f2 int, f3 int, f4 int, f5 int, f6 int, checked_out int);
 
3640
CREATE TABLE t2 ( f11 int PRIMARY KEY );
 
3641
INSERT INTO t1 VALUES (1,1,1,0,0,0,0),(2,1,1,3,8,1,0),(3,1,1,4,12,1,0);
 
3642
INSERT INTO t2 VALUES (62);
 
3643
SELECT * FROM t1 LEFT JOIN t2 ON f11 = t1.checked_out GROUP BY f1 ORDER BY f2, f3, f4, f5 LIMIT 0, 1;
 
3644
f1      f2      f3      f4      f5      f6      checked_out     f11
 
3645
1       1       1       0       0       0       0       NULL
 
3646
DROP TABLE t1, t2;
 
3647
DROP TABLE IF EXISTS t1;
 
3648
CREATE TABLE t1(a int);
 
3649
INSERT into t1 values (1), (2), (3);
 
3650
SELECT * FROM t1 LIMIT 2, -1;
 
3651
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 '-1' at line 1
 
3652
DROP TABLE t1;
 
3653
CREATE TABLE t1 (
 
3654
ID_with_null int NULL,
 
3655
ID_better int NOT NULL,
 
3656
INDEX idx1 (ID_with_null),
 
3657
INDEX idx2 (ID_better)
 
3658
);
 
3659
INSERT INTO t1 VALUES (1,1), (2,1), (null,3), (null,3), (null,3), (null,3);
 
3660
INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL;
 
3661
INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL;
 
3662
INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL;
 
3663
INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL;
 
3664
INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL;
 
3665
SELECT COUNT(*) FROM t1 WHERE ID_with_null IS NULL;
 
3666
COUNT(*)
 
3667
128
 
3668
SELECT COUNT(*) FROM t1 WHERE ID_better=1;
 
3669
COUNT(*)
 
3670
2
 
3671
EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID_with_null IS NULL;
 
3672
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
3673
1       SIMPLE  t1      ref     idx1,idx2       idx2    4       const   1       Using where
 
3674
DROP INDEX idx1 ON t1;
 
3675
CREATE UNIQUE INDEX idx1 ON t1(ID_with_null);
 
3676
EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID_with_null IS NULL;
 
3677
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
3678
1       SIMPLE  t1      ref     idx1,idx2       idx2    4       const   1       Using where
 
3679
DROP TABLE t1;
 
3680
CREATE TABLE t1 (
 
3681
ID1_with_null int NULL,
 
3682
ID2_with_null int NULL,
 
3683
ID_better int NOT NULL,
 
3684
INDEX idx1 (ID1_with_null, ID2_with_null),
 
3685
INDEX idx2 (ID_better)
 
3686
);
 
3687
INSERT INTO t1 VALUES (1,1,1), (2,2,1), (3,null,3), (null,3,3), (null,null,3),
 
3688
(3,null,3), (null,3,3), (null,null,3), (3,null,3), (null,3,3), (null,null,3);
 
3689
INSERT INTO t1 SELECT * FROM t1 WHERE ID1_with_null IS NULL;
 
3690
INSERT INTO t1 SELECT * FROM t1 WHERE ID2_with_null IS NULL;
 
3691
INSERT INTO t1 SELECT * FROM t1 WHERE ID1_with_null IS NULL;
 
3692
INSERT INTO t1 SELECT * FROM t1 WHERE ID2_with_null IS NULL;
 
3693
INSERT INTO t1 SELECT * FROM t1 WHERE ID1_with_null IS NULL;
 
3694
INSERT INTO t1 SELECT * FROM t1 WHERE ID2_with_null IS NULL;
 
3695
SELECT COUNT(*) FROM t1 WHERE ID1_with_null IS NULL AND ID2_with_null=3;
 
3696
COUNT(*)
 
3697
24
 
3698
SELECT COUNT(*) FROM t1 WHERE ID1_with_null=3 AND ID2_with_null IS NULL;
 
3699
COUNT(*)
 
3700
24
 
3701
SELECT COUNT(*) FROM t1 WHERE ID1_with_null IS NULL AND ID2_with_null IS NULL;
 
3702
COUNT(*)
 
3703
192
 
3704
SELECT COUNT(*) FROM t1 WHERE ID_better=1;
 
3705
COUNT(*)
 
3706
2
 
3707
EXPLAIN SELECT * FROM t1
 
3708
WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ;
 
3709
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
3710
1       SIMPLE  t1      ref     idx1,idx2       idx2    4       const   1       Using where
 
3711
EXPLAIN SELECT * FROM t1
 
3712
WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null=3 IS NULL ;
 
3713
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
3714
1       SIMPLE  t1      ref     idx1,idx2       idx2    4       const   1       Using where
 
3715
EXPLAIN SELECT * FROM t1
 
3716
WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null IS NULL;
 
3717
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
3718
1       SIMPLE  t1      ref     idx1,idx2       idx2    4       const   1       Using where
 
3719
DROP INDEX idx1 ON t1;
 
3720
CREATE UNIQUE INDEX idx1 ON t1(ID1_with_null,ID2_with_null);
 
3721
EXPLAIN SELECT * FROM t1
 
3722
WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ;
 
3723
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
3724
1       SIMPLE  t1      ref     idx1,idx2       idx2    4       const   1       Using where
 
3725
EXPLAIN SELECT * FROM t1
 
3726
WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null IS NULL ;
 
3727
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
3728
1       SIMPLE  t1      ref     idx1,idx2       idx2    4       const   1       Using where
 
3729
EXPLAIN SELECT * FROM t1
 
3730
WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null IS NULL;
 
3731
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
3732
1       SIMPLE  t1      ref     idx1,idx2       idx2    4       const   1       Using where
 
3733
EXPLAIN SELECT * FROM t1
 
3734
WHERE ID_better=1 AND ID1_with_null IS NULL AND 
 
3735
(ID2_with_null=1 OR ID2_with_null=2);
 
3736
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
3737
1       SIMPLE  t1      ref     idx1,idx2       idx2    4       const   1       Using where
 
3738
DROP TABLE t1;
 
3739
CREATE TABLE t1 (a INT, ts TIMESTAMP, KEY ts(ts));
 
3740
INSERT INTO t1 VALUES (30,"2006-01-03 23:00:00"), (31,"2006-01-03 23:00:00");
 
3741
ANALYZE TABLE t1;
 
3742
Table   Op      Msg_type        Msg_text
 
3743
test.t1 analyze status  OK
 
3744
CREATE TABLE t2 (a INT, dt1 DATETIME, dt2 DATETIME, PRIMARY KEY (a));
 
3745
INSERT INTO t2 VALUES (30, "2006-01-01 00:00:00", "2999-12-31 00:00:00");
 
3746
INSERT INTO t2 SELECT a+1,dt1,dt2 FROM t2;
 
3747
ANALYZE TABLE t2;
 
3748
Table   Op      Msg_type        Msg_text
 
3749
test.t2 analyze status  OK
 
3750
EXPLAIN
 
3751
SELECT * FROM t1 LEFT JOIN t2 ON (t1.a=t2.a) WHERE t1.a=30
 
3752
AND t1.ts BETWEEN t2.dt1 AND t2.dt2
 
3753
AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31";
 
3754
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
3755
1       SIMPLE  t2      const   PRIMARY PRIMARY 4       const   1       
 
3756
1       SIMPLE  t1      range   ts      ts      4       NULL    1       Using where
 
3757
Warnings:
 
3758
Warning 1292    Incorrect datetime value: '2999-12-31 00:00:00' for column 'ts' at row 1
 
3759
SELECT * FROM t1 LEFT JOIN t2 ON (t1.a=t2.a) WHERE t1.a=30
 
3760
AND t1.ts BETWEEN t2.dt1 AND t2.dt2
 
3761
AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31";
 
3762
a       ts      a       dt1     dt2
 
3763
30      2006-01-03 23:00:00     30      2006-01-01 00:00:00     2999-12-31 00:00:00
 
3764
Warnings:
 
3765
Warning 1292    Incorrect datetime value: '2999-12-31 00:00:00' for column 'ts' at row 1
 
3766
DROP TABLE t1,t2;
 
3767
create table t1 (a bigint unsigned);
 
3768
insert into t1 values
 
3769
(if(1, 9223372036854775808, 1)),
 
3770
(case when 1 then 9223372036854775808 else 1 end),
 
3771
(coalesce(9223372036854775808, 1));
 
3772
select * from t1;
 
3773
a
 
3774
9223372036854775808
 
3775
9223372036854775808
 
3776
9223372036854775808
 
3777
drop table t1;
 
3778
create table t1 select
 
3779
if(1, 9223372036854775808, 1) i,
 
3780
case when 1 then 9223372036854775808 else 1 end c,
 
3781
coalesce(9223372036854775808, 1) co;
 
3782
show create table t1;
 
3783
Table   Create Table
 
3784
t1      CREATE TABLE `t1` (
 
3785
  `i` decimal(19,0) NOT NULL DEFAULT '0',
 
3786
  `c` decimal(19,0) NOT NULL DEFAULT '0',
 
3787
  `co` decimal(19,0) NOT NULL DEFAULT '0'
 
3788
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
3789
drop table t1;
 
3790
select 
 
3791
if(1, cast(1111111111111111111 as unsigned), 1) i,
 
3792
case when 1 then cast(1111111111111111111 as unsigned) else 1 end c,
 
3793
coalesce(cast(1111111111111111111 as unsigned), 1) co;
 
3794
i       c       co
 
3795
1111111111111111111     1111111111111111111     1111111111111111111
 
3796
CREATE TABLE t1 (name varchar(255));
 
3797
CREATE TABLE t2 (name varchar(255), n int, KEY (name(3)));
 
3798
INSERT INTO t1 VALUES ('ccc'), ('bb'), ('cc '), ('aa  '), ('aa');
 
3799
INSERT INTO t2 VALUES ('bb',1), ('aa',2), ('cc   ',3);
 
3800
INSERT INTO t2 VALUES (concat('cc ', 0x06), 4);
 
3801
INSERT INTO t2 VALUES ('cc',5), ('bb ',6), ('cc ',7);
 
3802
SELECT * FROM t2;
 
3803
name    n
 
3804
bb      1
 
3805
aa      2
 
3806
cc      3
 
3807
cc     4
 
3808
cc      5
 
3809
bb      6
 
3810
cc      7
 
3811
SELECT * FROM t2 ORDER BY name;
 
3812
name    n
 
3813
aa      2
 
3814
bb      1
 
3815
bb      6
 
3816
cc     4
 
3817
cc      3
 
3818
cc      5
 
3819
cc      7
 
3820
SELECT name, LENGTH(name), n FROM t2 ORDER BY name;
 
3821
name    LENGTH(name)    n
 
3822
aa      2       2
 
3823
bb      2       1
 
3824
bb      3       6
 
3825
cc     4       4
 
3826
cc      5       3
 
3827
cc      2       5
 
3828
cc      3       7
 
3829
EXPLAIN SELECT name, LENGTH(name), n FROM t2 WHERE name='cc ';
 
3830
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
3831
1       SIMPLE  t2      ref     name    name    6       const   3       Using where
 
3832
SELECT name, LENGTH(name), n FROM t2 WHERE name='cc ';
 
3833
name    LENGTH(name)    n
 
3834
cc      5       3
 
3835
cc      2       5
 
3836
cc      3       7
 
3837
EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%';
 
3838
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
3839
1       SIMPLE  t2      range   name    name    6       NULL    3       Using where
 
3840
SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%';
 
3841
name    LENGTH(name)    n
 
3842
cc      5       3
 
3843
cc     4       4
 
3844
cc      2       5
 
3845
cc      3       7
 
3846
EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name;
 
3847
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
3848
1       SIMPLE  t2      range   name    name    6       NULL    3       Using where; Using filesort
 
3849
SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name;
 
3850
name    LENGTH(name)    n
 
3851
cc     4       4
 
3852
cc      5       3
 
3853
cc      2       5
 
3854
cc      3       7
 
3855
EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name;
 
3856
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
3857
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    5       
 
3858
1       SIMPLE  t2      ref     name    name    6       test.t1.name    2       
 
3859
SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name;
 
3860
name    name    n
 
3861
ccc     NULL    NULL
 
3862
bb      bb      1
 
3863
bb      bb      6
 
3864
cc      cc      3
 
3865
cc      cc      5
 
3866
cc      cc      7
 
3867
aa      aa      2
 
3868
aa      aa      2
 
3869
DROP TABLE t1,t2;
 
3870
CREATE TABLE t1 (name text);
 
3871
CREATE TABLE t2 (name text, n int, KEY (name(3)));
 
3872
INSERT INTO t1 VALUES ('ccc'), ('bb'), ('cc '), ('aa  '), ('aa');
 
3873
INSERT INTO t2 VALUES ('bb',1), ('aa',2), ('cc   ',3);
 
3874
INSERT INTO t2 VALUES (concat('cc ', 0x06), 4);
 
3875
INSERT INTO t2 VALUES ('cc',5), ('bb ',6), ('cc ',7);
 
3876
SELECT * FROM t2;
 
3877
name    n
 
3878
bb      1
 
3879
aa      2
 
3880
cc      3
 
3881
cc     4
 
3882
cc      5
 
3883
bb      6
 
3884
cc      7
 
3885
SELECT * FROM t2 ORDER BY name;
 
3886
name    n
 
3887
aa      2
 
3888
bb      1
 
3889
bb      6
 
3890
cc     4
 
3891
cc      3
 
3892
cc      5
 
3893
cc      7
 
3894
SELECT name, LENGTH(name), n FROM t2 ORDER BY name;
 
3895
name    LENGTH(name)    n
 
3896
aa      2       2
 
3897
bb      2       1
 
3898
bb      3       6
 
3899
cc     4       4
 
3900
cc      5       3
 
3901
cc      2       5
 
3902
cc      3       7
 
3903
EXPLAIN SELECT name, LENGTH(name), n FROM t2 WHERE name='cc ';
 
3904
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
3905
1       SIMPLE  t2      ref     name    name    6       const   3       Using where
 
3906
SELECT name, LENGTH(name), n FROM t2 WHERE name='cc ';
 
3907
name    LENGTH(name)    n
 
3908
cc      5       3
 
3909
cc      2       5
 
3910
cc      3       7
 
3911
EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%';
 
3912
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
3913
1       SIMPLE  t2      range   name    name    6       NULL    3       Using where
 
3914
SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%';
 
3915
name    LENGTH(name)    n
 
3916
cc      5       3
 
3917
cc     4       4
 
3918
cc      2       5
 
3919
cc      3       7
 
3920
EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name;
 
3921
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
3922
1       SIMPLE  t2      range   name    name    6       NULL    3       Using where; Using filesort
 
3923
SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name;
 
3924
name    LENGTH(name)    n
 
3925
cc     4       4
 
3926
cc      5       3
 
3927
cc      2       5
 
3928
cc      3       7
 
3929
EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name;
 
3930
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
3931
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    5       
 
3932
1       SIMPLE  t2      ref     name    name    6       test.t1.name    2       
 
3933
SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name;
 
3934
name    name    n
 
3935
ccc     NULL    NULL
 
3936
bb      bb      1
 
3937
bb      bb      6
 
3938
cc      cc      3
 
3939
cc      cc      5
 
3940
cc      cc      7
 
3941
aa      aa      2
 
3942
aa      aa      2
 
3943
DROP TABLE t1,t2;
 
3944
CREATE TABLE t1 (
 
3945
access_id int NOT NULL default '0',
 
3946
name varchar(20) default NULL,
 
3947
rank int NOT NULL default '0',
 
3948
KEY idx (access_id)
 
3949
);
 
3950
CREATE TABLE t2 (
 
3951
faq_group_id int NOT NULL default '0',
 
3952
faq_id int NOT NULL default '0',
 
3953
access_id int default NULL,
 
3954
UNIQUE KEY idx1 (faq_id),
 
3955
KEY idx2 (faq_group_id,faq_id)
 
3956
);
 
3957
INSERT INTO t1 VALUES 
 
3958
(1,'Everyone',2),(2,'Help',3),(3,'Technical Support',1),(4,'Chat User',4);
 
3959
INSERT INTO t2 VALUES
 
3960
(261,265,1),(490,494,1);
 
3961
SELECT t2.faq_id 
 
3962
FROM t1 INNER JOIN t2 IGNORE INDEX (idx1)
 
3963
ON (t1.access_id = t2.access_id)
 
3964
LEFT JOIN t2 t
 
3965
ON (t.faq_group_id = t2.faq_group_id AND
 
3966
find_in_set(t.access_id, '1,4') < find_in_set(t2.access_id, '1,4'))
 
3967
WHERE
 
3968
t2.access_id IN (1,4) AND t.access_id IS NULL AND t2.faq_id in (265);
 
3969
faq_id
 
3970
265
 
3971
SELECT t2.faq_id 
 
3972
FROM t1 INNER JOIN t2
 
3973
ON (t1.access_id = t2.access_id)
 
3974
LEFT JOIN t2 t
 
3975
ON (t.faq_group_id = t2.faq_group_id AND
 
3976
find_in_set(t.access_id, '1,4') < find_in_set(t2.access_id, '1,4'))
 
3977
WHERE
 
3978
t2.access_id IN (1,4) AND t.access_id IS NULL AND t2.faq_id in (265);
 
3979
faq_id
 
3980
265
 
3981
DROP TABLE t1,t2;
 
3982
CREATE TABLE t1 (a INT, b INT, KEY inx (b,a));
 
3983
INSERT INTO t1 VALUES (1,1), (1,2), (1,3), (1,4), (1,5), (1, 6), (1,7);
 
3984
EXPLAIN SELECT COUNT(*) FROM t1 f1 INNER JOIN t1 f2
 
3985
ON ( f1.b=f2.b AND f1.a<f2.a ) 
 
3986
WHERE 1 AND f1.b NOT IN (100,2232,3343,51111);
 
3987
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
3988
1       SIMPLE  f1      index   inx     inx     10      NULL    7       Using where; Using index
 
3989
1       SIMPLE  f2      ref     inx     inx     5       test.f1.b       1       Using where; Using index
 
3990
DROP TABLE t1;
 
3991
CREATE TABLE t1 (c1 INT, c2 INT);
 
3992
INSERT INTO t1 VALUES (1,11), (2,22), (2,22);
 
3993
EXPLAIN SELECT c1 FROM t1 WHERE (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT COUNT(c2)))))))))))))))))))))))))))))))) > 0;
 
3994
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
3995
1       PRIMARY t1      ALL     NULL    NULL    NULL    NULL    3       Using where
 
3996
31      DEPENDENT SUBQUERY      NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
 
3997
32      DEPENDENT SUBQUERY      NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
 
3998
EXPLAIN SELECT c1 FROM t1 WHERE (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT COUNT(c2))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) > 0;
 
3999
ERROR HY000: Too high level of nesting for select
 
4000
DROP TABLE t1;
 
4001
CREATE TABLE t1 (
 
4002
c1 int(11) NOT NULL AUTO_INCREMENT,
 
4003
c2 varchar(1000) DEFAULT NULL,
 
4004
c3 bigint(20) DEFAULT NULL,
 
4005
c4 bigint(20) DEFAULT NULL,
 
4006
PRIMARY KEY (c1)
 
4007
);
 
4008
EXPLAIN EXTENDED 
 
4009
SELECT  join_2.c1  
 
4010
FROM 
 
4011
t1 AS join_0, 
 
4012
t1 AS join_1, 
 
4013
t1 AS join_2, 
 
4014
t1 AS join_3, 
 
4015
t1 AS join_4, 
 
4016
t1 AS join_5, 
 
4017
t1 AS join_6, 
 
4018
t1 AS join_7
 
4019
WHERE 
 
4020
join_0.c1=join_1.c1  AND 
 
4021
join_1.c1=join_2.c1  AND 
 
4022
join_2.c1=join_3.c1  AND 
 
4023
join_3.c1=join_4.c1  AND 
 
4024
join_4.c1=join_5.c1  AND 
 
4025
join_5.c1=join_6.c1  AND 
 
4026
join_6.c1=join_7.c1 
 
4027
OR 
 
4028
join_0.c2 < '?'  AND 
 
4029
join_1.c2 < '?'  AND
 
4030
join_2.c2 > '?'  AND
 
4031
join_2.c2 < '!'  AND
 
4032
join_3.c2 > '?'  AND 
 
4033
join_4.c2 = '?'  AND 
 
4034
join_5.c2 <> '?' AND
 
4035
join_6.c2 <> '?' AND 
 
4036
join_7.c2 >= '?' AND
 
4037
join_0.c1=join_1.c1  AND 
 
4038
join_1.c1=join_2.c1  AND 
 
4039
join_2.c1=join_3.c1  AND
 
4040
join_3.c1=join_4.c1  AND 
 
4041
join_4.c1=join_5.c1  AND 
 
4042
join_5.c1=join_6.c1  AND 
 
4043
join_6.c1=join_7.c1
 
4044
GROUP BY 
 
4045
join_3.c1,
 
4046
join_2.c1,
 
4047
join_7.c1,
 
4048
join_1.c1,
 
4049
join_0.c1;
 
4050
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
4051
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    Impossible WHERE noticed after reading const tables
 
4052
Warnings:
 
4053
Note    1003    select NULL AS `c1` from `test`.`t1` `join_0` join `test`.`t1` `join_1` join `test`.`t1` `join_2` join `test`.`t1` `join_3` join `test`.`t1` `join_4` join `test`.`t1` `join_5` join `test`.`t1` `join_6` join `test`.`t1` `join_7` where 0 group by NULL,NULL,NULL,NULL,NULL
 
4054
SHOW WARNINGS;
 
4055
Level   Code    Message
 
4056
Note    1003    select NULL AS `c1` from `test`.`t1` `join_0` join `test`.`t1` `join_1` join `test`.`t1` `join_2` join `test`.`t1` `join_3` join `test`.`t1` `join_4` join `test`.`t1` `join_5` join `test`.`t1` `join_6` join `test`.`t1` `join_7` where 0 group by NULL,NULL,NULL,NULL,NULL
 
4057
DROP TABLE t1;
 
4058
SELECT 1 AS ` `;
 
4059
 
 
4060
1
 
4061
Warnings:
 
4062
Warning 1474    Name ' ' has become ''
 
4063
SELECT 1 AS `  `;
 
4064
 
 
4065
1
 
4066
Warnings:
 
4067
Warning 1474    Name '  ' has become ''
 
4068
SELECT 1 AS ` x`;
 
4069
x
 
4070
1
 
4071
Warnings:
 
4072
Warning 1466    Leading spaces are removed from name ' x'
 
4073
CREATE VIEW v1 AS SELECT 1 AS ``;
 
4074
ERROR 42000: Incorrect column name ''
 
4075
CREATE VIEW v1 AS SELECT 1 AS ` `;
 
4076
ERROR 42000: Incorrect column name ' '
 
4077
CREATE VIEW v1 AS SELECT 1 AS `  `;
 
4078
ERROR 42000: Incorrect column name '  '
 
4079
CREATE VIEW v1 AS SELECT (SELECT 1 AS `  `);
 
4080
ERROR 42000: Incorrect column name '  '
 
4081
CREATE VIEW v1 AS SELECT 1 AS ` x`;
 
4082
Warnings:
 
4083
Warning 1466    Leading spaces are removed from name ' x'
 
4084
SELECT `x` FROM v1;
 
4085
x
 
4086
1
 
4087
ALTER VIEW v1 AS SELECT 1 AS ` `;
 
4088
ERROR 42000: Incorrect column name ' '
 
4089
DROP VIEW v1;
 
4090
select str_to_date('2007-10-09','%Y-%m-%d') between '2007/10/01 00:00:00 GMT'
 
4091
                                                and '2007/10/20 00:00:00 GMT';
 
4092
str_to_date('2007-10-09','%Y-%m-%d') between '2007/10/01 00:00:00 GMT'
 
4093
                                                and '2007/10/20 00:00:00 GMT'
 
4094
1
 
4095
Warnings:
 
4096
Warning 1292    Truncated incorrect datetime value: '2007/10/01 00:00:00 GMT'
 
4097
Warning 1292    Truncated incorrect datetime value: '2007/10/20 00:00:00 GMT'
 
4098
select str_to_date('2007-10-09','%Y-%m-%d') > '2007/10/01 00:00:00 GMT-6';
 
4099
str_to_date('2007-10-09','%Y-%m-%d') > '2007/10/01 00:00:00 GMT-6'
 
4100
1
 
4101
Warnings:
 
4102
Warning 1292    Truncated incorrect date value: '2007/10/01 00:00:00 GMT-6'
 
4103
select str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/2000:00:00 GMT-6';
 
4104
str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/2000:00:00 GMT-6'
 
4105
1
 
4106
Warnings:
 
4107
Warning 1292    Truncated incorrect date value: '2007/10/2000:00:00 GMT-6'
 
4108
select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6';
 
4109
str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6'
 
4110
1
 
4111
Warnings:
 
4112
Warning 1292    Truncated incorrect date value: '2007-10-1 00:00:00 GMT-6'
 
4113
select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 x00:00:00 GMT-6';
 
4114
str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 x00:00:00 GMT-6'
 
4115
1
 
4116
Warnings:
 
4117
Warning 1292    Truncated incorrect date value: '2007-10-01 x00:00:00 GMT-6'
 
4118
select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:00:00 GMT-6';
 
4119
str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:00:00 GMT-6'
 
4120
1
 
4121
Warnings:
 
4122
Warning 1292    Truncated incorrect datetime value: '2007-10-01 00:00:00 GMT-6'
 
4123
select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:x00:00 GMT-6';
 
4124
str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:x00:00 GMT-6'
 
4125
1
 
4126
Warnings:
 
4127
Warning 1292    Truncated incorrect datetime value: '2007-10-01 00:x00:00 GMT-6'
 
4128
select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 x12:34:56 GMT-6';
 
4129
str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 x12:34:56 GMT-6'
 
4130
1
 
4131
Warnings:
 
4132
Warning 1292    Truncated incorrect datetime value: '2007-10-01 x12:34:56 GMT-6'
 
4133
select str_to_date('2007-10-01 12:34:00','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6';
 
4134
str_to_date('2007-10-01 12:34:00','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6'
 
4135
1
 
4136
Warnings:
 
4137
Warning 1292    Truncated incorrect datetime value: '2007-10-01 12:34x:56 GMT-6'
 
4138
select str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6';
 
4139
str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6'
 
4140
0
 
4141
Warnings:
 
4142
Warning 1292    Truncated incorrect datetime value: '2007-10-01 12:34x:56 GMT-6'
 
4143
select str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34:56';
 
4144
str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34:56'
 
4145
1
 
4146
select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 12:00:00';
 
4147
str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 12:00:00'
 
4148
0
 
4149
select str_to_date('2007-10-01 12','%Y-%m-%d %H') = '2007-10-01 12:00:00';
 
4150
str_to_date('2007-10-01 12','%Y-%m-%d %H') = '2007-10-01 12:00:00'
 
4151
1
 
4152
select str_to_date('2007-10-01 12:34','%Y-%m-%d %H') = '2007-10-01 12:00:00';
 
4153
str_to_date('2007-10-01 12:34','%Y-%m-%d %H') = '2007-10-01 12:00:00'
 
4154
1
 
4155
Warnings:
 
4156
Warning 1292    Truncated incorrect datetime value: '2007-10-01 12:34'
 
4157
select str_to_date('2007-02-30 12:34','%Y-%m-%d %H:%i') = '2007-02-30 12:34';
 
4158
str_to_date('2007-02-30 12:34','%Y-%m-%d %H:%i') = '2007-02-30 12:34'
 
4159
1
 
4160
select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34';
 
4161
str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'
 
4162
1
 
4163
select str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01 00:00:00'
 
4164
                                                and '2007/10/20 00:00:00';
 
4165
str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01 00:00:00'
 
4166
                                                and '2007/10/20 00:00:00'
 
4167
1
 
4168
set SQL_MODE=TRADITIONAL;
 
4169
select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34';
 
4170
str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'
 
4171
0
 
4172
Warnings:
 
4173
Warning 1292    Truncated incorrect datetime value: '2007-10-00 12:34'
 
4174
select str_to_date('2007-10-01 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34';
 
4175
str_to_date('2007-10-01 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'
 
4176
0
 
4177
Warnings:
 
4178
Warning 1292    Truncated incorrect datetime value: '2007-10-00 12:34'
 
4179
select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34';
 
4180
str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34'
 
4181
0
 
4182
Warnings:
 
4183
Warning 1292    Truncated incorrect datetime value: '2007-10-00 12:34:00'
 
4184
select str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01'
 
4185
                                                and '2007/10/20';
 
4186
str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01'
 
4187
                                                and '2007/10/20'
 
4188
0
 
4189
Warnings:
 
4190
Warning 1292    Incorrect datetime value: '2007-10-00' for column '2007/09/01' at row 1
 
4191
Warning 1292    Incorrect datetime value: '2007-10-00' for column '2007/10/20' at row 1
 
4192
set SQL_MODE=DEFAULT;
 
4193
select str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20';
 
4194
str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20'
 
4195
1
 
4196
Warnings:
 
4197
Warning 1292    Truncated incorrect datetime value: ''
 
4198
select str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20';
 
4199
str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20'
 
4200
0
 
4201
select str_to_date('','%Y-%m-%d %H:%i') = '2007-10-01 12:34';
 
4202
str_to_date('','%Y-%m-%d %H:%i') = '2007-10-01 12:34'
 
4203
0
 
4204
select str_to_date(NULL,'%Y-%m-%d %H:%i') = '2007-10-01 12:34';
 
4205
str_to_date(NULL,'%Y-%m-%d %H:%i') = '2007-10-01 12:34'
 
4206
NULL
 
4207
select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '';
 
4208
str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = ''
 
4209
0
 
4210
Warnings:
 
4211
Warning 1292    Truncated incorrect datetime value: ''
 
4212
select str_to_date('1','%Y-%m-%d') = '1';
 
4213
str_to_date('1','%Y-%m-%d') = '1'
 
4214
0
 
4215
Warnings:
 
4216
Warning 1292    Truncated incorrect date value: '1'
 
4217
select str_to_date('1','%Y-%m-%d') = '1';
 
4218
str_to_date('1','%Y-%m-%d') = '1'
 
4219
0
 
4220
Warnings:
 
4221
Warning 1292    Truncated incorrect date value: '1'
 
4222
select str_to_date('','%Y-%m-%d') = '';
 
4223
str_to_date('','%Y-%m-%d') = ''
 
4224
0
 
4225
Warnings:
 
4226
Warning 1292    Truncated incorrect date value: ''
 
4227
select str_to_date('1000-01-01','%Y-%m-%d') between '0000-00-00' and NULL;
 
4228
str_to_date('1000-01-01','%Y-%m-%d') between '0000-00-00' and NULL
 
4229
0
 
4230
select str_to_date('1000-01-01','%Y-%m-%d') between NULL and '2000-00-00';
 
4231
str_to_date('1000-01-01','%Y-%m-%d') between NULL and '2000-00-00'
 
4232
0
 
4233
select str_to_date('1000-01-01','%Y-%m-%d') between NULL and NULL;
 
4234
str_to_date('1000-01-01','%Y-%m-%d') between NULL and NULL
 
4235
0
 
4236
CREATE TABLE t1 (c11 INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY);
 
4237
CREATE TABLE t2 (c21 INT UNSIGNED NOT NULL, 
 
4238
c22 INT DEFAULT NULL, 
 
4239
KEY(c21, c22));
 
4240
CREATE TABLE t3 (c31 INT UNSIGNED NOT NULL DEFAULT 0, 
 
4241
c32 INT DEFAULT NULL, 
 
4242
c33 INT NOT NULL, 
 
4243
c34 INT UNSIGNED DEFAULT 0,
 
4244
KEY (c33, c34, c32));
 
4245
INSERT INTO t1 values (),(),(),(),();
 
4246
INSERT INTO t2 SELECT a.c11, b.c11 FROM t1 a, t1 b;
 
4247
INSERT INTO t3 VALUES (1, 1, 1, 0), 
 
4248
(2, 2, 0, 0), 
 
4249
(3, 3, 1, 0), 
 
4250
(4, 4, 0, 0), 
 
4251
(5, 5, 1, 0);
 
4252
SELECT c32 FROM t1, t2, t3 WHERE t1.c11 IN (1, 3, 5) AND 
 
4253
t3.c31 = t1.c11 AND t2.c21 = t1.c11 AND 
 
4254
t3.c33 = 1 AND t2.c22 in (1, 3) 
 
4255
ORDER BY c32;
 
4256
c32
 
4257
1
 
4258
1
 
4259
3
 
4260
3
 
4261
5
 
4262
5
 
4263
SELECT c32 FROM t1, t2, t3 WHERE t1.c11 IN (1, 3, 5) AND 
 
4264
t3.c31 = t1.c11 AND t2.c21 = t1.c11 AND 
 
4265
t3.c33 = 1 AND t2.c22 in (1, 3) 
 
4266
ORDER BY c32 DESC;
 
4267
c32
 
4268
5
 
4269
5
 
4270
3
 
4271
3
 
4272
1
 
4273
1
 
4274
DROP TABLE t1, t2, t3;
 
4275
 
 
4276
#
 
4277
# Bug#30736: Row Size Too Large Error Creating a Table and
 
4278
# Inserting Data.
 
4279
#
 
4280
DROP TABLE IF EXISTS t1;
 
4281
DROP TABLE IF EXISTS t2;
 
4282
 
 
4283
CREATE TABLE t1(
 
4284
c1 DECIMAL(10, 2),
 
4285
c2 FLOAT);
 
4286
 
 
4287
INSERT INTO t1 VALUES (0, 1), (2, 3), (4, 5);
 
4288
 
 
4289
CREATE TABLE t2(
 
4290
c3 DECIMAL(10, 2))
 
4291
SELECT
 
4292
c1 * c2 AS c3
 
4293
FROM t1;
 
4294
 
 
4295
SELECT * FROM t1;
 
4296
c1      c2
 
4297
0.00    1
 
4298
2.00    3
 
4299
4.00    5
 
4300
 
 
4301
SELECT * FROM t2;
 
4302
c3
 
4303
0.00
 
4304
6.00
 
4305
20.00
 
4306
 
 
4307
DROP TABLE t1;
 
4308
DROP TABLE t2;
 
4309
 
 
4310
CREATE TABLE t1 (c1 BIGINT NOT NULL);
 
4311
INSERT INTO t1 (c1) VALUES (1);
 
4312
SELECT * FROM t1 WHERE c1 > NULL + 1;
 
4313
c1
 
4314
DROP TABLE t1;
 
4315
 
 
4316
CREATE TABLE t1 (a VARCHAR(10) NOT NULL PRIMARY KEY);
 
4317
INSERT INTO t1 (a) VALUES ('foo0'), ('bar0'), ('baz0');
 
4318
SELECT * FROM t1 WHERE a IN (CONCAT('foo', 0), 'bar');
 
4319
a
 
4320
foo0
 
4321
DROP TABLE t1;
 
4322
CREATE TABLE t1 (a INT, b INT);
 
4323
CREATE TABLE t2 (a INT, c INT, KEY(a));
 
4324
INSERT INTO t1 VALUES (1, 1), (2, 2);
 
4325
INSERT INTO t2 VALUES (1, 1), (1, 2), (1, 3), (1, 4), (1, 5),
 
4326
(2, 1), (2, 2), (2, 3), (2, 4), (2, 5),
 
4327
(3, 1), (3, 2), (3, 3), (3, 4), (3, 5),
 
4328
(4, 1), (4, 2), (4, 3), (4, 4), (4, 5);
 
4329
FLUSH STATUS;
 
4330
SELECT DISTINCT b FROM t1 LEFT JOIN t2 USING(a) WHERE c <= 3;
 
4331
b
 
4332
1
 
4333
2
 
4334
SHOW STATUS LIKE 'Handler_read%';
 
4335
Variable_name   Value
 
4336
Handler_read_first      0
 
4337
Handler_read_key        2
 
4338
Handler_read_next       0
 
4339
Handler_read_prev       0
 
4340
Handler_read_rnd        0
 
4341
Handler_read_rnd_next   6
 
4342
DROP TABLE t1, t2;
 
4343
CREATE TABLE t1 (f1 bigint(20) NOT NULL default '0',
 
4344
f2 int(11) NOT NULL default '0',
 
4345
f3 bigint(20) NOT NULL default '0',
 
4346
f4 varchar(255) NOT NULL default '',
 
4347
PRIMARY KEY (f1),
 
4348
KEY key1 (f4),
 
4349
KEY key2 (f2));
 
4350
CREATE TABLE t2 (f1 int(11) NOT NULL default '0',
 
4351
f2 enum('A1','A2','A3') NOT NULL default 'A1',
 
4352
f3 int(11) NOT NULL default '0',
 
4353
PRIMARY KEY (f1),
 
4354
KEY key1 (f3));
 
4355
CREATE TABLE t3 (f1 bigint(20) NOT NULL default '0',
 
4356
f2 datetime NOT NULL default '1980-01-01 00:00:00',
 
4357
PRIMARY KEY (f1));
 
4358
insert into t1 values (1, 1, 1, 'abc');
 
4359
insert into t1 values (2, 1, 2, 'def');
 
4360
insert into t1 values (3, 1, 2, 'def');
 
4361
insert into t2 values (1, 'A1', 1);
 
4362
insert into t3 values (1, '1980-01-01');
 
4363
SELECT a.f3, cr.f4, count(*) count
 
4364
FROM t2 a
 
4365
STRAIGHT_JOIN t1 cr ON cr.f2 = a.f1
 
4366
LEFT JOIN
 
4367
(t1 cr2
 
4368
JOIN t3 ae2 ON cr2.f3 = ae2.f1
 
4369
) ON a.f1 = cr2.f2 AND ae2.f2 < now() - INTERVAL 7 DAY AND
 
4370
cr.f4 = cr2.f4
 
4371
GROUP BY a.f3, cr.f4;
 
4372
f3      f4      count
 
4373
1       abc     1
 
4374
1       def     2
 
4375
drop table t1, t2, t3;
 
4376
CREATE TABLE t1 (a INT KEY, b INT);
 
4377
INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4);
 
4378
EXPLAIN EXTENDED SELECT a, b FROM t1 WHERE a > 1 AND a = b LIMIT 2;
 
4379
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
4380
1       SIMPLE  t1      range   PRIMARY PRIMARY 4       NULL    3       100.00  Using where
 
4381
Warnings:
 
4382
Note    1003    select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` > 1)) limit 2
 
4383
EXPLAIN EXTENDED SELECT a, b FROM t1 WHERE a > 1 AND b = a LIMIT 2;
 
4384
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
4385
1       SIMPLE  t1      range   PRIMARY PRIMARY 4       NULL    3       100.00  Using where
 
4386
Warnings:
 
4387
Note    1003    select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` > 1)) limit 2
 
4388
DROP TABLE t1;
 
4389
#
 
4390
# Bug#47019: Assertion failed: 0, file .\rt_mbr.c, line 138 when 
 
4391
# forcing a spatial index
 
4392
#
 
4393
CREATE TABLE t1(a LINESTRING NOT NULL, SPATIAL KEY(a));
 
4394
INSERT INTO t1 VALUES
 
4395
(GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)')),
 
4396
(GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)'));
 
4397
EXPLAIN SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2;
 
4398
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
4399
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    2       
 
4400
1       SIMPLE  t2      ALL     a       NULL    NULL    NULL    2       
 
4401
SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2;
 
4402
1
 
4403
1
 
4404
1
 
4405
1
 
4406
1
 
4407
EXPLAIN SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2 FORCE INDEX(a);
 
4408
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
4409
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    2       
 
4410
1       SIMPLE  t2      ALL     a       NULL    NULL    NULL    2       
 
4411
SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2 FORCE INDEX(a);
 
4412
1
 
4413
1
 
4414
1
 
4415
1
 
4416
1
 
4417
DROP TABLE t1;
 
4418
#
 
4419
# Bug #48291 : crash with row() operator,select into @var, and 
 
4420
#   subquery returning multiple rows
 
4421
#
 
4422
CREATE TABLE t1(a INT);
 
4423
INSERT INTO t1 VALUES (2),(3);
 
4424
# Should not crash
 
4425
SELECT 1 FROM t1 WHERE a <> 1 AND NOT
 
4426
ROW(a,a) <=> ROW((SELECT 1 FROM t1 WHERE 1=2),(SELECT 1 FROM t1))
 
4427
INTO @var0;
 
4428
ERROR 21000: Subquery returns more than 1 row
 
4429
DROP TABLE t1;
 
4430
#
 
4431
# Bug #48458: simple query tries to allocate enormous amount of
 
4432
#   memory
 
4433
#
 
4434
CREATE TABLE t1(a INT NOT NULL, b YEAR);
 
4435
INSERT INTO t1 VALUES ();
 
4436
Warnings:
 
4437
Warning 1364    Field 'a' doesn't have a default value
 
4438
CREATE TABLE t2(c INT);
 
4439
# Should not err out because of out-of-memory
 
4440
SELECT 1 FROM t2 JOIN t1 ON 1=1
 
4441
WHERE a != '1' AND NOT a >= b OR NOT ROW(b,a )<> ROW(a,a);
 
4442
1
 
4443
DROP TABLE t1,t2;
 
4444
#
 
4445
# Bug #49199: Optimizer handles incorrectly: 
 
4446
# field='const1' AND field='const2' in some cases
 
4447
 
 
4448
CREATE TABLE t1(a DATETIME NOT NULL);
 
4449
INSERT INTO t1 VALUES('2001-01-01');
 
4450
SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00';
 
4451
a
 
4452
2001-01-01 00:00:00
 
4453
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00';
 
4454
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
4455
1       SIMPLE  t1      system  NULL    NULL    NULL    NULL    1       100.00  
 
4456
Warnings:
 
4457
Note    1003    select '2001-01-01 00:00:00' AS `a` from `test`.`t1` where 1
 
4458
DROP TABLE t1;
 
4459
CREATE TABLE t1(a DATE NOT NULL);
 
4460
INSERT INTO t1 VALUES('2001-01-01');
 
4461
SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00';
 
4462
a
 
4463
2001-01-01
 
4464
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00';
 
4465
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
4466
1       SIMPLE  t1      system  NULL    NULL    NULL    NULL    1       100.00  
 
4467
Warnings:
 
4468
Note    1003    select '2001-01-01' AS `a` from `test`.`t1` where 1
 
4469
DROP TABLE t1;
 
4470
CREATE TABLE t1(a TIMESTAMP NOT NULL);
 
4471
INSERT INTO t1 VALUES('2001-01-01');
 
4472
SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00';
 
4473
a
 
4474
2001-01-01 00:00:00
 
4475
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00';
 
4476
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
4477
1       SIMPLE  t1      system  NULL    NULL    NULL    NULL    1       100.00  
 
4478
Warnings:
 
4479
Note    1003    select '2001-01-01 00:00:00' AS `a` from `test`.`t1` where 1
 
4480
DROP TABLE t1;
 
4481
CREATE TABLE t1(a DATETIME NOT NULL, b DATE NOT NULL);
 
4482
INSERT INTO t1 VALUES('2001-01-01', '2001-01-01');
 
4483
SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00';
 
4484
a       b
 
4485
2001-01-01 00:00:00     2001-01-01
 
4486
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00';
 
4487
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
4488
1       SIMPLE  t1      system  NULL    NULL    NULL    NULL    1       100.00  
 
4489
Warnings:
 
4490
Note    1003    select '2001-01-01 00:00:00' AS `a`,'2001-01-01' AS `b` from `test`.`t1` where 1
 
4491
DROP TABLE t1;
 
4492
CREATE TABLE t1(a DATETIME NOT NULL, b VARCHAR(20) NOT NULL);
 
4493
INSERT INTO t1 VALUES('2001-01-01', '2001-01-01');
 
4494
SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00';
 
4495
a       b
 
4496
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00';
 
4497
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
4498
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    Impossible WHERE noticed after reading const tables
 
4499
Warnings:
 
4500
Note    1003    select '2001-01-01 00:00:00' AS `a`,'2001-01-01' AS `b` from `test`.`t1` where 0
 
4501
SELECT * FROM t1 WHERE a='2001-01-01 00:00:00' AND a=b AND b='2001-01-01';
 
4502
a       b
 
4503
2001-01-01 00:00:00     2001-01-01
 
4504
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a='2001-01-01 00:00:00' AND a=b AND b='2001-01-01';
 
4505
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
4506
1       SIMPLE  t1      system  NULL    NULL    NULL    NULL    1       100.00  
 
4507
Warnings:
 
4508
Note    1003    select '2001-01-01 00:00:00' AS `a`,'2001-01-01' AS `b` from `test`.`t1` where 1
 
4509
DROP TABLE t1;
 
4510
CREATE TABLE t1(a DATETIME NOT NULL, b DATE NOT NULL);
 
4511
INSERT INTO t1 VALUES('2001-01-01', '2001-01-01');
 
4512
SELECT x.a, y.a, z.a FROM t1 x 
 
4513
JOIN t1 y ON x.a=y.a 
 
4514
JOIN t1 z ON y.a=z.a 
 
4515
WHERE x.a='2001-01-01' AND z.a='2001-01-01 00:00:00';
 
4516
a       a       a
 
4517
2001-01-01 00:00:00     2001-01-01 00:00:00     2001-01-01 00:00:00
 
4518
EXPLAIN EXTENDED SELECT x.a, y.a, z.a FROM t1 x 
 
4519
JOIN t1 y ON x.a=y.a 
 
4520
JOIN t1 z ON y.a=z.a 
 
4521
WHERE x.a='2001-01-01' AND z.a='2001-01-01 00:00:00';
 
4522
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
4523
1       SIMPLE  x       system  NULL    NULL    NULL    NULL    1       100.00  
 
4524
1       SIMPLE  y       system  NULL    NULL    NULL    NULL    1       100.00  
 
4525
1       SIMPLE  z       system  NULL    NULL    NULL    NULL    1       100.00  
 
4526
Warnings:
 
4527
Note    1003    select '2001-01-01 00:00:00' AS `a`,'2001-01-01 00:00:00' AS `a`,'2001-01-01 00:00:00' AS `a` from `test`.`t1` `x` join `test`.`t1` `y` join `test`.`t1` `z` where 1
 
4528
DROP TABLE t1;
 
4529
#
 
4530
# Bug #49897: crash in ptr_compare when char(0) NOT NULL 
 
4531
# column is used for ORDER BY
 
4532
#
 
4533
SET @old_sort_buffer_size= @@session.sort_buffer_size;
 
4534
SET @@sort_buffer_size= 40000;
 
4535
CREATE TABLE t1(a CHAR(0) NOT NULL);
 
4536
INSERT INTO t1 VALUES (0), (0), (0);
 
4537
INSERT INTO t1 SELECT t11.a FROM t1 t11, t1 t12;
 
4538
INSERT INTO t1 SELECT t11.a FROM t1 t11, t1 t12;
 
4539
INSERT INTO t1 SELECT t11.a FROM t1 t11, t1 t12;
 
4540
EXPLAIN SELECT a FROM t1 ORDER BY a;
 
4541
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
4542
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    24492   
 
4543
SELECT a FROM t1 ORDER BY a;
 
4544
DROP TABLE t1;
 
4545
CREATE TABLE t1(a CHAR(0) NOT NULL, b CHAR(0) NOT NULL, c int);
 
4546
INSERT INTO t1 VALUES (0, 0, 0), (0, 0, 2), (0, 0, 1);
 
4547
INSERT INTO t1 SELECT t11.a, t11.b, t11.c FROM t1 t11, t1 t12;
 
4548
INSERT INTO t1 SELECT t11.a, t11.b, t11.c FROM t1 t11, t1 t12;
 
4549
INSERT INTO t1 SELECT t11.a, t11.b, t11.c FROM t1 t11, t1 t12;
 
4550
EXPLAIN SELECT a FROM t1 ORDER BY a LIMIT 5;
 
4551
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
4552
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    24492   
 
4553
SELECT a FROM t1 ORDER BY a LIMIT 5;
 
4554
a
 
4555
 
 
4556
 
 
4557
 
 
4558
 
 
4559
 
 
4560
EXPLAIN SELECT * FROM t1 ORDER BY a, b LIMIT 5;
 
4561
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
4562
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    24492   
 
4563
SELECT * FROM t1 ORDER BY a, b LIMIT 5;
 
4564
a       b       c
 
4565
                0
 
4566
                2
 
4567
                1
 
4568
                0
 
4569
                2
 
4570
EXPLAIN SELECT * FROM t1 ORDER BY a, b, c LIMIT 5;
 
4571
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
4572
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    24492   Using filesort
 
4573
SELECT * FROM t1 ORDER BY a, b, c LIMIT 5;
 
4574
a       b       c
 
4575
                0
 
4576
                0
 
4577
                0
 
4578
                0
 
4579
                0
 
4580
EXPLAIN SELECT * FROM t1 ORDER BY c, a LIMIT 5;
 
4581
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
4582
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    24492   Using filesort
 
4583
SELECT * FROM t1 ORDER BY c, a LIMIT 5;
 
4584
a       b       c
 
4585
                0
 
4586
                0
 
4587
                0
 
4588
                0
 
4589
                0
 
4590
SET @@sort_buffer_size= @old_sort_buffer_size;
 
4591
DROP TABLE t1;
 
4592
End of 5.0 tests
 
4593
create table t1(a INT, KEY (a));
 
4594
INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
 
4595
SELECT a FROM t1 ORDER BY a LIMIT 2;
 
4596
a
 
4597
1
 
4598
2
 
4599
SELECT a FROM t1 ORDER BY a LIMIT 2,4294967296;
 
4600
a
 
4601
3
 
4602
4
 
4603
5
 
4604
SELECT a FROM t1 ORDER BY a LIMIT 2,4294967297;
 
4605
a
 
4606
3
 
4607
4
 
4608
5
 
4609
DROP TABLE t1;
 
4610
CREATE TABLE A (date_key date);
 
4611
CREATE TABLE C (
 
4612
pk int,
 
4613
int_nokey int,
 
4614
int_key int,
 
4615
date_key date NOT NULL,
 
4616
date_nokey date,
 
4617
varchar_key varchar(1)
 
4618
);
 
4619
INSERT INTO C VALUES 
 
4620
(1,1,1,'0000-00-00',NULL,NULL),
 
4621
(1,1,1,'0000-00-00',NULL,NULL);
 
4622
SELECT 1 FROM C WHERE pk > ANY (SELECT 1 FROM C);
 
4623
1
 
4624
SELECT COUNT(DISTINCT 1) FROM C 
 
4625
WHERE date_key = (SELECT 1 FROM A WHERE C.date_key IS NULL) GROUP BY pk;
 
4626
COUNT(DISTINCT 1)
 
4627
SELECT date_nokey FROM C 
 
4628
WHERE int_key IN (SELECT 1 FROM A) 
 
4629
HAVING date_nokey = '10:41:7' 
 
4630
ORDER BY date_key;
 
4631
date_nokey
 
4632
Warnings:
 
4633
Warning 1292    Incorrect date value: '10:41:7' for column 'date_nokey' at row 1
 
4634
DROP TABLE A,C;
 
4635
CREATE TABLE t1 (a INT NOT NULL, b INT);
 
4636
INSERT INTO t1 VALUES (1, 1);
 
4637
EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2;
 
4638
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
4639
1       SIMPLE  t1      system  NULL    NULL    NULL    NULL    1       100.00  
 
4640
Warnings:
 
4641
Note    1003    select '1' AS `a`,'1' AS `b` from `test`.`t1` where 1
 
4642
SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2;
 
4643
a       b
 
4644
1       1
 
4645
DROP TABLE t1;
 
4646
CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, c INT NOT NULL);
 
4647
EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND b=b AND c=c) OR b > 20;
 
4648
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
4649
1       SIMPLE  t1      system  NULL    NULL    NULL    NULL    0       0.00    const row not found
 
4650
Warnings:
 
4651
Note    1003    select NULL AS `a`,NULL AS `b`,NULL AS `c` from `test`.`t1` where 1
 
4652
EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND a=a AND b=b) OR b > 20;
 
4653
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
4654
1       SIMPLE  t1      system  NULL    NULL    NULL    NULL    0       0.00    const row not found
 
4655
Warnings:
 
4656
Note    1003    select NULL AS `a`,NULL AS `b`,NULL AS `c` from `test`.`t1` where 1
 
4657
EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND b=b AND a=a) OR b > 20;
 
4658
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
4659
1       SIMPLE  t1      system  NULL    NULL    NULL    NULL    0       0.00    const row not found
 
4660
Warnings:
 
4661
Note    1003    select NULL AS `a`,NULL AS `b`,NULL AS `c` from `test`.`t1` where 1
 
4662
DROP TABLE t1;
 
4663
#
 
4664
# Bug#45266: Uninitialized variable lead to an empty result.
 
4665
#
 
4666
drop table if exists A,AA,B,BB;
 
4667
CREATE TABLE `A` (
 
4668
`pk` int(11) NOT NULL AUTO_INCREMENT,
 
4669
`date_key` date NOT NULL,
 
4670
`date_nokey` date NOT NULL,
 
4671
`datetime_key` datetime NOT NULL,
 
4672
`int_nokey` int(11) NOT NULL,
 
4673
`time_key` time NOT NULL,
 
4674
`time_nokey` time NOT NULL,
 
4675
PRIMARY KEY (`pk`),
 
4676
KEY `date_key` (`date_key`),
 
4677
KEY `time_key` (`time_key`),
 
4678
KEY `datetime_key` (`datetime_key`)
 
4679
);
 
4680
CREATE TABLE `AA` (
 
4681
`pk` int(11) NOT NULL AUTO_INCREMENT,
 
4682
`int_nokey` int(11) NOT NULL,
 
4683
`time_key` time NOT NULL,
 
4684
KEY `time_key` (`time_key`),
 
4685
PRIMARY KEY (`pk`)
 
4686
);
 
4687
CREATE TABLE `B` (
 
4688
`date_nokey` date NOT NULL,
 
4689
`date_key` date NOT NULL,
 
4690
`time_key` time NOT NULL,
 
4691
`datetime_nokey` datetime NOT NULL,
 
4692
`varchar_key` varchar(1) NOT NULL,
 
4693
KEY `date_key` (`date_key`),
 
4694
KEY `time_key` (`time_key`),
 
4695
KEY `varchar_key` (`varchar_key`)
 
4696
);
 
4697
INSERT INTO `B` VALUES ('2003-07-28','2003-07-28','15:13:38','0000-00-00 00:00:00','f'),('0000-00-00','0000-00-00','00:05:48','2004-07-02 14:34:13','x');
 
4698
CREATE TABLE `BB` (
 
4699
`pk` int(11) NOT NULL AUTO_INCREMENT,
 
4700
`int_nokey` int(11) NOT NULL,
 
4701
`date_key` date NOT NULL,
 
4702
`varchar_nokey` varchar(1) NOT NULL,
 
4703
`date_nokey` date NOT NULL,
 
4704
PRIMARY KEY (`pk`),
 
4705
KEY `date_key` (`date_key`)
 
4706
);
 
4707
INSERT INTO `BB` VALUES (10,8,'0000-00-00','i','0000-00-00'),(11,0,'2005-08-18','','2005-08-18');
 
4708
SELECT table1 . `pk` AS field1 
 
4709
FROM 
 
4710
(BB AS table1 INNER JOIN 
 
4711
(AA AS table2 STRAIGHT_JOIN A AS table3 
 
4712
ON ( table3 . `date_key` = table2 . `pk` ))
 
4713
ON ( table3 . `datetime_key` = table2 . `int_nokey` ))
 
4714
WHERE  ( table3 . `date_key` <= 4 AND table2 . `pk` = table1 . `varchar_nokey`)
 
4715
GROUP BY field1 ;
 
4716
field1
 
4717
SELECT table3 .`date_key` field1
 
4718
FROM
 
4719
B table1 LEFT JOIN B table3 JOIN
 
4720
(BB table6 JOIN A table7 ON table6 .`varchar_nokey`)
 
4721
ON table6 .`int_nokey` ON table6 .`date_key`
 
4722
  WHERE  NOT ( table1 .`varchar_key`  AND table7 .`pk`) GROUP  BY field1;
 
4723
field1
 
4724
NULL
 
4725
SELECT table4 . `time_nokey` AS field1 FROM 
 
4726
(AA AS table1 CROSS JOIN 
 
4727
(AA AS table2 STRAIGHT_JOIN 
 
4728
(B AS table3 STRAIGHT_JOIN A AS table4 
 
4729
ON ( table4 . `date_key` = table3 . `time_key` ))
 
4730
ON ( table4 . `pk` = table3 . `date_nokey` ))
 
4731
ON ( table4 . `time_key` = table3 . `datetime_nokey` ))
 
4732
WHERE  ( table4 . `time_key` < table1 . `time_key` AND
 
4733
table1 . `int_nokey` != 'f')
 
4734
GROUP BY field1  ORDER BY field1 , field1;
 
4735
field1
 
4736
SELECT table1 .`time_key` field2  FROM B table1  LEFT JOIN  BB JOIN A table5 ON table5 .`date_nokey`  ON table5 .`int_nokey` GROUP  BY field2;
 
4737
field2
 
4738
00:05:48
 
4739
15:13:38
 
4740
drop table A,AA,B,BB;
 
4741
#end of test for bug#45266
 
4742
 
4743
# BUG#48052: Valgrind warning - uninitialized value in init_read_record()
 
4744
 
4745
CREATE TABLE t1 (
 
4746
pk int(11) NOT NULL,
 
4747
i int(11) DEFAULT NULL,
 
4748
v varchar(1) DEFAULT NULL,
 
4749
PRIMARY KEY (pk)
 
4750
);
 
4751
INSERT INTO t1 VALUES (2,7,'m');
 
4752
INSERT INTO t1 VALUES (3,9,'m');
 
4753
SELECT  v
 
4754
FROM t1
 
4755
WHERE NOT pk > 0  
 
4756
HAVING v <= 't' 
 
4757
ORDER BY pk;
 
4758
v
 
4759
DROP TABLE t1;
 
4760
#
 
4761
# Bug#49489 Uninitialized cache led to a wrong result.
 
4762
#
 
4763
CREATE TABLE t1(c1 DOUBLE(5,4));
 
4764
INSERT INTO t1 VALUES (9.1234);
 
4765
SELECT * FROM t1 WHERE c1 < 9.12345;
 
4766
c1
 
4767
9.1234
 
4768
DROP TABLE t1;
 
4769
# End of test for bug#49489.
 
4770
#
 
4771
# Bug #49517: Inconsistent behavior while using 
 
4772
# NULLable BIGINT and INT columns in comparison
 
4773
#
 
4774
CREATE TABLE t1(a BIGINT UNSIGNED NOT NULL, b BIGINT NULL, c INT NULL);
 
4775
INSERT INTO t1 VALUES(105, NULL, NULL);
 
4776
SELECT * FROM t1 WHERE b < 102;
 
4777
a       b       c
 
4778
SELECT * FROM t1 WHERE c < 102;
 
4779
a       b       c
 
4780
SELECT * FROM t1 WHERE 102 < b;
 
4781
a       b       c
 
4782
SELECT * FROM t1 WHERE 102 < c;
 
4783
a       b       c
 
4784
DROP TABLE t1;
 
4785
#
 
4786
# Bug #54459: Assertion failed: param.sort_length, 
 
4787
# file .\filesort.cc, line 149 (part II)
 
4788
#
 
4789
CREATE TABLE t1(a ENUM('') NOT NULL);
 
4790
INSERT INTO t1 VALUES (), (), ();
 
4791
EXPLAIN SELECT 1 FROM t1 ORDER BY a COLLATE latin1_german2_ci;
 
4792
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
4793
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    3       
 
4794
SELECT 1 FROM t1 ORDER BY a COLLATE latin1_german2_ci;
 
4795
1
 
4796
1
 
4797
1
 
4798
1
 
4799
DROP TABLE t1;
 
4800
End of 5.1 tests