1
drop table if exists t1, t2, t3;
3
event_date datetime DEFAULT '2014-02-22' NOT NULL,
4
obtype int DEFAULT '0' NOT NULL,
5
event_id int DEFAULT '0' NOT NULL,
7
PRIMARY KEY (event_date,obtype,event_id)
9
INSERT INTO t1(event_date,obtype,event_id) VALUES ('1999-07-10',100100,24), ('1999-07-11',100100,25),
10
('1999-07-13',100600,0), ('1999-07-13',100600,4), ('1999-07-13',100600,26),
11
('1999-07-14',100600,10), ('1999-07-15',100600,16), ('1999-07-15',100800,45),
12
('1999-07-15',101000,47), ('1999-07-16',100800,46), ('1999-07-20',100600,5),
13
('1999-07-20',100600,27), ('1999-07-21',100600,11), ('1999-07-22',100600,17),
14
('1999-07-23',100100,39), ('1999-07-24',100100,39), ('1999-07-24',100500,40),
15
('1999-07-25',100100,39), ('1999-07-27',100600,1), ('1999-07-27',100600,6),
16
('1999-07-27',100600,28), ('1999-07-28',100600,12), ('1999-07-29',100500,41),
17
('1999-07-29',100600,18), ('1999-07-30',100500,41), ('1999-07-31',100500,41),
18
('1999-08-01',100700,34), ('1999-08-03',100600,7), ('1999-08-03',100600,29),
19
('1999-08-04',100600,13), ('1999-08-05',100500,42), ('1999-08-05',100600,19),
20
('1999-08-06',100500,42), ('1999-08-07',100500,42), ('1999-08-08',100500,42),
21
('1999-08-10',100600,2), ('1999-08-10',100600,9), ('1999-08-10',100600,30),
22
('1999-08-11',100600,14), ('1999-08-12',100600,20), ('1999-08-17',100500,8),
23
('1999-08-17',100600,31), ('1999-08-18',100600,15), ('1999-08-19',100600,22),
24
('1999-08-24',100600,3), ('1999-08-24',100600,32), ('1999-08-27',100500,43),
25
('1999-08-31',100600,33), ('1999-09-17',100100,37), ('1999-09-18',100100,37),
26
('1999-09-19',100100,37), ('2000-12-18',100700,38);
27
select event_date,obtype,event_id from t1 WHERE event_date >= '1999-07-01' AND event_date < '1999-07-15' AND (obtype=100600 OR obtype=100100) ORDER BY event_date;
28
event_date obtype event_id
29
1999-07-10 00:00:00 100100 24
30
1999-07-11 00:00:00 100100 25
31
1999-07-13 00:00:00 100600 0
32
1999-07-13 00:00:00 100600 4
33
1999-07-13 00:00:00 100600 26
34
1999-07-14 00:00:00 100600 10
35
select event_date,obtype,event_id from t1 WHERE event_date >= '1999-07-01' AND event_date <= '1999-07-15' AND (obtype=100600 OR obtype=100100) or event_date >= '1999-07-01' AND event_date <= '1999-07-15' AND obtype=100099;
36
event_date obtype event_id
37
1999-07-10 00:00:00 100100 24
38
1999-07-11 00:00:00 100100 25
39
1999-07-13 00:00:00 100600 0
40
1999-07-13 00:00:00 100600 4
41
1999-07-13 00:00:00 100600 26
42
1999-07-14 00:00:00 100600 10
43
1999-07-15 00:00:00 100600 16
46
PAPER_ID smallint DEFAULT '0' NOT NULL,
47
YEAR smallint DEFAULT '0' NOT NULL,
48
ISSUE smallint DEFAULT '0' NOT NULL,
49
CLOSED tinyint DEFAULT '0' NOT NULL,
50
ISS_DATE datetime DEFAULT '2014-02-22' NOT NULL,
51
PRIMARY KEY (PAPER_ID,YEAR,ISSUE)
53
INSERT INTO t1 VALUES (3,1999,34,0,'1999-07-12'), (1,1999,111,0,'1999-03-23'),
54
(1,1999,222,0,'1999-03-23'), (3,1999,33,0,'1999-07-12'),
55
(3,1999,32,0,'1999-07-12'), (3,1999,31,0,'1999-07-12'),
56
(3,1999,30,0,'1999-07-12'), (3,1999,29,0,'1999-07-12'),
57
(3,1999,28,0,'1999-07-12'), (1,1999,40,1,'1999-05-01'),
58
(1,1999,41,1,'1999-05-01'), (1,1999,42,1,'1999-05-01'),
59
(1,1999,46,1,'1999-05-01'), (1,1999,47,1,'1999-05-01'),
60
(1,1999,48,1,'1999-05-01'), (1,1999,49,1,'1999-05-01'),
61
(1,1999,50,0,'1999-05-01'), (1,1999,51,0,'1999-05-01'),
62
(1,1999,200,0,'1999-06-28'), (1,1999,52,0,'1999-06-28'),
63
(1,1999,53,0,'1999-06-28'), (1,1999,54,0,'1999-06-28'),
64
(1,1999,55,0,'1999-06-28'), (1,1999,56,0,'1999-07-01'),
65
(1,1999,57,0,'1999-07-01'), (1,1999,58,0,'1999-07-01'),
66
(1,1999,59,0,'1999-07-01'), (1,1999,60,0,'1999-07-01'),
67
(3,1999,35,0,'1999-07-12');
68
select YEAR,ISSUE from t1 where PAPER_ID=3 and (YEAR>1999 or (YEAR=1999 and ISSUE>28)) order by YEAR,ISSUE;
79
id int NOT NULL auto_increment,
80
parent_id int DEFAULT '0' NOT NULL,
81
`level` tinyint DEFAULT '0' NOT NULL,
84
INSERT INTO t1 VALUES (1,0,0), (3,1,1), (4,1,1), (8,2,2), (9,2,2), (17,3,2),
85
(22,4,2), (24,4,2), (28,5,2), (29,5,2), (30,5,2), (31,6,2), (32,6,2), (33,6,2),
86
(203,7,2), (202,7,2), (20,3,2), (157,0,0), (193,5,2), (40,7,2), (2,1,1),
87
(15,2,2), (6,1,1), (34,6,2), (35,6,2), (16,3,2), (7,1,1), (36,7,2), (18,3,2),
88
(26,5,2), (27,5,2), (183,4,2), (38,7,2), (25,5,2), (37,7,2), (21,4,2),
89
(19,3,2), (5,1,1), (179,5,2);
90
SELECT * FROM t1 WHERE `level` = 1 AND parent_id = 1;
98
SELECT * FROM t1 WHERE `level` = 1 AND parent_id = 1 order by id;
108
Satellite varchar(25) not null,
109
SensorMode varchar(25) not null,
110
FullImageCornersUpperLeftLongitude double not null,
111
FullImageCornersUpperRightLongitude double not null,
112
FullImageCornersUpperRightLatitude double not null,
113
FullImageCornersLowerRightLatitude double not null,
114
primary key(Satellite,SensorMode));
115
insert into t1 values('OV-3','PAN1',91,-92,40,50);
116
insert into t1 values('OV-4','PAN1',91,-92,40,50);
117
select * from t1 where t1.Satellite = 'OV-3' and t1.SensorMode = 'PAN1' and t1.FullImageCornersUpperLeftLongitude > -90.000000 and t1.FullImageCornersUpperRightLongitude < -82.000000;
118
Satellite SensorMode FullImageCornersUpperLeftLongitude FullImageCornersUpperRightLongitude FullImageCornersUpperRightLatitude FullImageCornersLowerRightLatitude
119
OV-3 PAN1 91 -92 40 50
121
create table t1 ( aString char(100) not null default '', primary key (aString) , extra char(100));
122
insert into t1 (aString) values ( 'believe in myself' ), ( 'believe' ), ('baaa' ), ( 'believe in love');
123
select * from t1 where aString < 'believe in myself' order by aString;
128
select * from t1 where aString > 'believe in love' order by aString;
130
believe in myself NULL
134
art binary(1) NOT NULL default '',
135
KNR char(5) NOT NULL default '',
136
RECHNR char(6) NOT NULL default '',
137
POSNR char(2) NOT NULL default '',
138
ARTNR char(10) NOT NULL default '',
139
TEX char(70) NOT NULL default '',
142
INSERT INTO t1 (t1ID,art) VALUES
343
select count(*) from t1 where upper(art) = 'J';
346
select count(*) from t1 where art = 'J' or art = 'j';
349
select count(*) from t1 where art = 'j' or art = 'J';
352
select count(*) from t1 where art = 'j';
355
select count(*) from t1 where art = 'J';
365
INSERT INTO t1(a,b) VALUES
366
(1,1),(2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1),(10,2),
367
(13,2),(14,2),(15,2),(16,2),(17,3),(16,3),(19,3),(20,3),
368
(21,4),(22,5),(23,5),(24,5),(25,5),(26,5),(30,5),(31,5),(32,5),
370
SELECT * FROM t1 WHERE a IN(1,2) AND b=5;
373
create table t1(c1 varchar(1024),c2 varchar(1024), c3 varchar(1024), primary key(c1,c2,c3), extra varchar(1024));
374
insert into t1(c1,c2,c3) values ('s1_1','s1_2','s1_3'),('s2_1','s2_2','s2_3');
375
select * from t1 where c1 in ('s1_1','s2_1') and c2 in ('s2_1','s1_2');
379
create table t2 (x bigint not null primary key, y bigint);
380
insert into t2(x) values (-16);
381
insert into t2(x) values (-15);
386
select count(*) from t2 where x>0;
389
select count(*) from t2 where x=0;
392
select count(*) from t2 where x<0;
395
select count(*) from t2 where x < -16;
398
select count(*) from t2 where x = -16;
401
select count(*) from t2 where x > -16;
404
select count(*) from t2 where x = 1844674407370955160;
409
c1 char(10) primary key, c2 char(10), c3 char(10), c4 char(10),
410
c5 char(10), c6 char(10), c7 char(10), c8 char(10),
411
c9 char(10), c10 char(10), c11 char(10), c12 char(10),
412
c13 char(10), c14 char(10), c15 char(10), c16 char(10)
414
insert into t1 (c1) values ('1');
415
select * from t1 where
416
c1 in ('abcdefgh', '123456789', 'qwertyuio', 'asddfgh',
417
'abcdefg1', '123456781', 'qwertyui1', 'asddfg1',
418
'abcdefg2', '123456782', 'qwertyui2', 'asddfg2',
419
'abcdefg3', '123456783', 'qwertyui3', 'asddfg3',
420
'abcdefg4', '123456784', 'qwertyui4', 'asddfg4',
421
'abcdefg5', '123456785', 'qwertyui5', 'asddfg5',
422
'abcdefg6', '123456786', 'qwertyui6', 'asddfg6',
423
'abcdefg7', '123456787', 'qwertyui7', 'asddfg7',
424
'abcdefg8', '123456788', 'qwertyui8', 'asddfg8',
425
'abcdefg9', '123456789', 'qwertyui9', 'asddfg9',
426
'abcdefgA', '12345678A', 'qwertyuiA', 'asddfgA',
427
'abcdefgB', '12345678B', 'qwertyuiB', 'asddfgB',
428
'abcdefgC', '12345678C', 'qwertyuiC', 'asddfgC')
429
and c2 in ('abcdefgh', '123456789', 'qwertyuio', 'asddfgh',
430
'abcdefg1', '123456781', 'qwertyui1', 'asddfg1',
431
'abcdefg2', '123456782', 'qwertyui2', 'asddfg2',
432
'abcdefg3', '123456783', 'qwertyui3', 'asddfg3',
433
'abcdefg4', '123456784', 'qwertyui4', 'asddfg4',
434
'abcdefg5', '123456785', 'qwertyui5', 'asddfg5',
435
'abcdefg6', '123456786', 'qwertyui6', 'asddfg6',
436
'abcdefg7', '123456787', 'qwertyui7', 'asddfg7',
437
'abcdefg8', '123456788', 'qwertyui8', 'asddfg8',
438
'abcdefg9', '123456789', 'qwertyui9', 'asddfg9',
439
'abcdefgA', '12345678A', 'qwertyuiA', 'asddfgA',
440
'abcdefgB', '12345678B', 'qwertyuiB', 'asddfgB',
441
'abcdefgC', '12345678C', 'qwertyuiC', 'asddfgC')
442
and c3 in ('abcdefgh', '123456789', 'qwertyuio', 'asddfgh',
443
'abcdefg1', '123456781', 'qwertyui1', 'asddfg1',
444
'abcdefg2', '123456782', 'qwertyui2', 'asddfg2',
445
'abcdefg3', '123456783', 'qwertyui3', 'asddfg3',
446
'abcdefg4', '123456784', 'qwertyui4', 'asddfg4',
447
'abcdefg5', '123456785', 'qwertyui5', 'asddfg5',
448
'abcdefg6', '123456786', 'qwertyui6', 'asddfg6',
449
'abcdefg7', '123456787', 'qwertyui7', 'asddfg7',
450
'abcdefg8', '123456788', 'qwertyui8', 'asddfg8',
451
'abcdefg9', '123456789', 'qwertyui9', 'asddfg9',
452
'abcdefgA', '12345678A', 'qwertyuiA', 'asddfgA',
453
'abcdefgB', '12345678B', 'qwertyuiB', 'asddfgB',
454
'abcdefgC', '12345678C', 'qwertyuiC', 'asddfgC')
455
and c4 in ('abcdefgh', '123456789', 'qwertyuio', 'asddfgh',
456
'abcdefg1', '123456781', 'qwertyui1', 'asddfg1',
457
'abcdefg2', '123456782', 'qwertyui2', 'asddfg2',
458
'abcdefg3', '123456783', 'qwertyui3', 'asddfg3',
459
'abcdefg4', '123456784', 'qwertyui4', 'asddfg4',
460
'abcdefg5', '123456785', 'qwertyui5', 'asddfg5',
461
'abcdefg6', '123456786', 'qwertyui6', 'asddfg6',
462
'abcdefg7', '123456787', 'qwertyui7', 'asddfg7',
463
'abcdefg8', '123456788', 'qwertyui8', 'asddfg8',
464
'abcdefg9', '123456789', 'qwertyui9', 'asddfg9',
465
'abcdefgA', '12345678A', 'qwertyuiA', 'asddfgA',
466
'abcdefgB', '12345678B', 'qwertyuiB', 'asddfgB',
467
'abcdefgC', '12345678C', 'qwertyuiC', 'asddfgC')
468
and c5 in ('abcdefgh', '123456789', 'qwertyuio', 'asddfgh',
469
'abcdefg1', '123456781', 'qwertyui1', 'asddfg1',
470
'abcdefg2', '123456782', 'qwertyui2', 'asddfg2',
471
'abcdefg3', '123456783', 'qwertyui3', 'asddfg3',
472
'abcdefg4', '123456784', 'qwertyui4', 'asddfg4',
473
'abcdefg5', '123456785', 'qwertyui5', 'asddfg5',
474
'abcdefg6', '123456786', 'qwertyui6', 'asddfg6',
475
'abcdefg7', '123456787', 'qwertyui7', 'asddfg7',
476
'abcdefg8', '123456788', 'qwertyui8', 'asddfg8',
477
'abcdefg9', '123456789', 'qwertyui9', 'asddfg9',
478
'abcdefgA', '12345678A', 'qwertyuiA', 'asddfgA',
479
'abcdefgB', '12345678B', 'qwertyuiB', 'asddfgB',
480
'abcdefgC', '12345678C', 'qwertyuiC', 'asddfgC')
481
and c6 in ('abcdefgh', '123456789', 'qwertyuio', 'asddfgh',
482
'abcdefg1', '123456781', 'qwertyui1', 'asddfg1',
483
'abcdefg2', '123456782', 'qwertyui2', 'asddfg2',
484
'abcdefg3', '123456783', 'qwertyui3', 'asddfg3',
485
'abcdefg4', '123456784', 'qwertyui4', 'asddfg4',
486
'abcdefg5', '123456785', 'qwertyui5', 'asddfg5',
487
'abcdefg6', '123456786', 'qwertyui6', 'asddfg6',
488
'abcdefg7', '123456787', 'qwertyui7', 'asddfg7',
489
'abcdefg8', '123456788', 'qwertyui8', 'asddfg8',
490
'abcdefg9', '123456789', 'qwertyui9', 'asddfg9',
491
'abcdefgA', '12345678A', 'qwertyuiA', 'asddfgA',
492
'abcdefgB', '12345678B', 'qwertyuiB', 'asddfgB',
493
'abcdefgC', '12345678C', 'qwertyuiC', 'asddfgC')
494
and c7 in ('abcdefgh', '123456789', 'qwertyuio', 'asddfgh',
495
'abcdefg1', '123456781', 'qwertyui1', 'asddfg1',
496
'abcdefg2', '123456782', 'qwertyui2', 'asddfg2',
497
'abcdefg3', '123456783', 'qwertyui3', 'asddfg3',
498
'abcdefg4', '123456784', 'qwertyui4', 'asddfg4',
499
'abcdefg5', '123456785', 'qwertyui5', 'asddfg5',
500
'abcdefg6', '123456786', 'qwertyui6', 'asddfg6',
501
'abcdefg7', '123456787', 'qwertyui7', 'asddfg7',
502
'abcdefg8', '123456788', 'qwertyui8', 'asddfg8',
503
'abcdefg9', '123456789', 'qwertyui9', 'asddfg9',
504
'abcdefgA', '12345678A', 'qwertyuiA', 'asddfgA',
505
'abcdefgB', '12345678B', 'qwertyuiB', 'asddfgB',
506
'abcdefgC', '12345678C', 'qwertyuiC', 'asddfgC')
507
and c8 in ('abcdefgh', '123456789', 'qwertyuio', 'asddfgh',
508
'abcdefg1', '123456781', 'qwertyui1', 'asddfg1',
509
'abcdefg2', '123456782', 'qwertyui2', 'asddfg2',
510
'abcdefg3', '123456783', 'qwertyui3', 'asddfg3',
511
'abcdefg4', '123456784', 'qwertyui4', 'asddfg4',
512
'abcdefg5', '123456785', 'qwertyui5', 'asddfg5',
513
'abcdefg6', '123456786', 'qwertyui6', 'asddfg6',
514
'abcdefg7', '123456787', 'qwertyui7', 'asddfg7',
515
'abcdefg8', '123456788', 'qwertyui8', 'asddfg8',
516
'abcdefg9', '123456789', 'qwertyui9', 'asddfg9',
517
'abcdefgA', '12345678A', 'qwertyuiA', 'asddfgA',
518
'abcdefgB', '12345678B', 'qwertyuiB', 'asddfgB',
519
'abcdefgC', '12345678C', 'qwertyuiC', 'asddfgC')
520
and c9 in ('abcdefgh', '123456789', 'qwertyuio', 'asddfgh',
521
'abcdefg1', '123456781', 'qwertyui1', 'asddfg1',
522
'abcdefg2', '123456782', 'qwertyui2', 'asddfg2',
523
'abcdefg3', '123456783', 'qwertyui3', 'asddfg3',
524
'abcdefg4', '123456784', 'qwertyui4', 'asddfg4',
525
'abcdefg5', '123456785', 'qwertyui5', 'asddfg5',
526
'abcdefg6', '123456786', 'qwertyui6', 'asddfg6',
527
'abcdefg7', '123456787', 'qwertyui7', 'asddfg7',
528
'abcdefg8', '123456788', 'qwertyui8', 'asddfg8',
529
'abcdefg9', '123456789', 'qwertyui9', 'asddfg9',
530
'abcdefgA', '12345678A', 'qwertyuiA', 'asddfgA',
531
'abcdefgB', '12345678B', 'qwertyuiB', 'asddfgB',
532
'abcdefgC', '12345678C', 'qwertyuiC', 'asddfgC')
533
and c10 in ('abcdefgh', '123456789', 'qwertyuio', 'asddfgh',
534
'abcdefg1', '123456781', 'qwertyui1', 'asddfg1',
535
'abcdefg2', '123456782', 'qwertyui2', 'asddfg2',
536
'abcdefg3', '123456783', 'qwertyui3', 'asddfg3',
537
'abcdefg4', '123456784', 'qwertyui4', 'asddfg4',
538
'abcdefg5', '123456785', 'qwertyui5', 'asddfg5',
539
'abcdefg6', '123456786', 'qwertyui6', 'asddfg6',
540
'abcdefg7', '123456787', 'qwertyui7', 'asddfg7',
541
'abcdefg8', '123456788', 'qwertyui8', 'asddfg8',
542
'abcdefg9', '123456789', 'qwertyui9', 'asddfg9',
543
'abcdefgA', '12345678A', 'qwertyuiA', 'asddfgA',
544
'abcdefgB', '12345678B', 'qwertyuiB', 'asddfgB',
545
'abcdefgC', '12345678C', 'qwertyuiC', 'asddfgC');
546
c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16