~linuxjedi/drizzle/trunk-bug-667053

« back to all changes in this revision

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

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

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