~drizzle-pbxt/drizzle/drizzle-pbxt

« back to all changes in this revision

Viewing changes to tests/r/pbxt/range.result

  • Committer: Paul McCullagh
  • Date: 2009-04-08 13:29:19 UTC
  • Revision ID: paul.mccullagh@primebase.org-20090408132919-mjgj7u5n813bm6pd
Fixed some tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
drop table if exists t1, t2, t3;
 
2
CREATE TABLE t1 (
 
3
event_date date NULL,
 
4
type int DEFAULT '0' NOT NULL,
 
5
event_id int DEFAULT '0' NOT NULL,
 
6
PRIMARY KEY (event_date,type,event_id)
 
7
);
 
8
INSERT INTO t1 VALUES ('1999-07-10',100100,24), ('1999-07-11',100100,25),
 
9
('1999-07-13',100600,0), ('1999-07-13',100600,4), ('1999-07-13',100600,26),
 
10
('1999-07-14',100600,10), ('1999-07-15',100600,16), ('1999-07-15',100800,45),
 
11
('1999-07-15',101000,47), ('1999-07-16',100800,46), ('1999-07-20',100600,5),
 
12
('1999-07-20',100600,27), ('1999-07-21',100600,11), ('1999-07-22',100600,17),
 
13
('1999-07-23',100100,39), ('1999-07-24',100100,39), ('1999-07-24',100500,40),
 
14
('1999-07-25',100100,39), ('1999-07-27',100600,1), ('1999-07-27',100600,6),
 
15
('1999-07-27',100600,28), ('1999-07-28',100600,12), ('1999-07-29',100500,41),
 
16
('1999-07-29',100600,18), ('1999-07-30',100500,41), ('1999-07-31',100500,41),
 
17
('1999-08-01',100700,34), ('1999-08-03',100600,7), ('1999-08-03',100600,29),
 
18
('1999-08-04',100600,13), ('1999-08-05',100500,42), ('1999-08-05',100600,19),
 
19
('1999-08-06',100500,42), ('1999-08-07',100500,42), ('1999-08-08',100500,42),
 
20
('1999-08-10',100600,2), ('1999-08-10',100600,9), ('1999-08-10',100600,30),
 
21
('1999-08-11',100600,14), ('1999-08-12',100600,20), ('1999-08-17',100500,8),
 
22
('1999-08-17',100600,31), ('1999-08-18',100600,15), ('1999-08-19',100600,22),
 
23
('1999-08-24',100600,3), ('1999-08-24',100600,32), ('1999-08-27',100500,43),
 
24
('1999-08-31',100600,33), ('1999-09-17',100100,37), ('1999-09-18',100100,37),
 
25
('1999-09-19',100100,37), ('2000-12-18',100700,38);
 
26
select event_date,type,event_id from t1 WHERE event_date >= "1999-07-01" AND event_date < "1999-07-15" AND (type=100600 OR type=100100) ORDER BY event_date;
 
27
event_date      type    event_id
 
28
1999-07-10      100100  24
 
29
1999-07-11      100100  25
 
30
1999-07-13      100600  0
 
31
1999-07-13      100600  4
 
32
1999-07-13      100600  26
 
33
1999-07-14      100600  10
 
34
explain select event_date,type,event_id from t1 WHERE type = 100601 and event_date >= "1999-07-01" AND event_date < "1999-07-15" AND (type=100600 OR type=100100) ORDER BY event_date;
 
35
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
36
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    Impossible WHERE
 
37
select event_date,type,event_id from t1 WHERE event_date >= "1999-07-01" AND event_date <= "1999-07-15" AND (type=100600 OR type=100100) or event_date >= "1999-07-01" AND event_date <= "1999-07-15" AND type=100099;
 
38
event_date      type    event_id
 
39
1999-07-10      100100  24
 
40
1999-07-11      100100  25
 
41
1999-07-13      100600  0
 
42
1999-07-13      100600  4
 
43
1999-07-13      100600  26
 
44
1999-07-14      100600  10
 
45
1999-07-15      100600  16
 
46
drop table t1;
 
47
CREATE TABLE t1 (
 
48
PAPER_ID int DEFAULT '0' NOT NULL,
 
49
YEAR int DEFAULT '0' NOT NULL,
 
50
ISSUE int DEFAULT '0' NOT NULL,
 
51
CLOSED int DEFAULT '0' NOT NULL,
 
52
ISS_DATE date,
 
53
PRIMARY KEY (PAPER_ID,YEAR,ISSUE)
 
54
);
 
55
INSERT INTO t1 VALUES (3,1999,34,0,'1999-07-12'), (1,1999,111,0,'1999-03-23'),
 
56
(1,1999,222,0,'1999-03-23'), (3,1999,33,0,'1999-07-12'),
 
57
(3,1999,32,0,'1999-07-12'), (3,1999,31,0,'1999-07-12'),
 
58
(3,1999,30,0,'1999-07-12'), (3,1999,29,0,'1999-07-12'),
 
59
(3,1999,28,0,'1999-07-12'), (1,1999,40,1,'1999-05-01'),
 
60
(1,1999,41,1,'1999-05-01'), (1,1999,42,1,'1999-05-01'),
 
61
(1,1999,46,1,'1999-05-01'), (1,1999,47,1,'1999-05-01'),
 
62
(1,1999,48,1,'1999-05-01'), (1,1999,49,1,'1999-05-01'),
 
63
(1,1999,50,0,'1999-05-01'), (1,1999,51,0,'1999-05-01'),
 
64
(1,1999,200,0,'1999-06-28'), (1,1999,52,0,'1999-06-28'),
 
65
(1,1999,53,0,'1999-06-28'), (1,1999,54,0,'1999-06-28'),
 
66
(1,1999,55,0,'1999-06-28'), (1,1999,56,0,'1999-07-01'),
 
67
(1,1999,57,0,'1999-07-01'), (1,1999,58,0,'1999-07-01'),
 
68
(1,1999,59,0,'1999-07-01'), (1,1999,60,0,'1999-07-01'),
 
69
(3,1999,35,0,'1999-07-12');
 
70
select YEAR,ISSUE from t1 where PAPER_ID=3 and (YEAR>1999 or (YEAR=1999 and ISSUE>28))  order by YEAR,ISSUE;
 
71
YEAR    ISSUE
 
72
1999    29
 
73
1999    30
 
74
1999    31
 
75
1999    32
 
76
1999    33
 
77
1999    34
 
78
1999    35
 
79
check table t1;
 
80
Table   Op      Msg_type        Msg_text
 
81
test.t1 check   status  OK
 
82
repair table t1;
 
83
Table   Op      Msg_type        Msg_text
 
84
test.t1 repair  status  OK
 
85
drop table t1;
 
86
CREATE TABLE t1 (
 
87
id int NOT NULL auto_increment,
 
88
parent_id int DEFAULT '0' NOT NULL,
 
89
level int DEFAULT '0' NOT NULL,
 
90
PRIMARY KEY (id),
 
91
KEY parent_id (parent_id),
 
92
KEY level (level)
 
93
);
 
94
INSERT INTO t1 VALUES (1,0,0), (3,1,1), (4,1,1), (8,2,2), (9,2,2), (17,3,2),
 
95
(22,4,2), (24,4,2), (28,5,2), (29,5,2), (30,5,2), (31,6,2), (32,6,2), (33,6,2),
 
96
(203,7,2), (202,7,2), (20,3,2), (157,0,0), (193,5,2), (40,7,2), (2,1,1),
 
97
(15,2,2), (6,1,1), (34,6,2), (35,6,2), (16,3,2), (7,1,1), (36,7,2), (18,3,2),
 
98
(26,5,2), (27,5,2), (183,4,2), (38,7,2), (25,5,2), (37,7,2), (21,4,2),
 
99
(19,3,2), (5,1,1), (179,5,2);
 
100
SELECT * FROM t1 WHERE level = 1 AND parent_id = 1;
 
101
id      parent_id       level
 
102
3       1       1
 
103
4       1       1
 
104
2       1       1
 
105
6       1       1
 
106
7       1       1
 
107
5       1       1
 
108
SELECT * FROM t1 WHERE level = 1 AND parent_id = 1 order by id;
 
109
id      parent_id       level
 
110
2       1       1
 
111
3       1       1
 
112
4       1       1
 
113
5       1       1
 
114
6       1       1
 
115
7       1       1
 
116
drop table t1;
 
117
create table t1(
 
118
Satellite               varchar(25)     not null,
 
119
SensorMode              varchar(25)     not null,
 
120
FullImageCornersUpperLeftLongitude      double  not null,
 
121
FullImageCornersUpperRightLongitude     double  not null,
 
122
FullImageCornersUpperRightLatitude      double  not null,
 
123
FullImageCornersLowerRightLatitude      double  not null,
 
124
index two (Satellite, SensorMode, FullImageCornersUpperLeftLongitude, FullImageCornersUpperRightLongitude, FullImageCornersUpperRightLatitude, FullImageCornersLowerRightLatitude));
 
125
insert into t1 values("OV-3","PAN1",91,-92,40,50);
 
126
insert into t1 values("OV-4","PAN1",91,-92,40,50);
 
127
select * from t1 where t1.Satellite = "OV-3" and t1.SensorMode = "PAN1" and t1.FullImageCornersUpperLeftLongitude > -90.000000 and t1.FullImageCornersUpperRightLongitude < -82.000000;
 
128
Satellite       SensorMode      FullImageCornersUpperLeftLongitude      FullImageCornersUpperRightLongitude     FullImageCornersUpperRightLatitude      FullImageCornersLowerRightLatitude
 
129
OV-3    PAN1    91      -92     40      50
 
130
drop table t1;
 
131
create table t1 ( aString char(100) not null default "", key aString (aString(10)) );
 
132
insert t1 (aString) values ( "believe in myself" ), ( "believe" ), ("baaa" ), ( "believe in love");
 
133
select * from t1 where aString < "believe in myself" order by aString;
 
134
aString
 
135
baaa
 
136
believe
 
137
believe in love
 
138
select * from t1 where aString > "believe in love" order by aString;
 
139
aString
 
140
believe in myself
 
141
alter table t1 drop key aString;
 
142
select * from t1 where aString < "believe in myself" order by aString;
 
143
aString
 
144
baaa
 
145
believe
 
146
believe in love
 
147
select * from t1 where aString > "believe in love" order by aString;
 
148
aString
 
149
believe in myself
 
150
drop table t1;
 
151
CREATE TABLE t1 (
 
152
t1ID int NOT NULL auto_increment,
 
153
art varbinary(1) NOT NULL default '',
 
154
KNR char(5) NOT NULL default '',
 
155
RECHNR char(6) NOT NULL default '',
 
156
POSNR char(2) NOT NULL default '',
 
157
ARTNR char(10) NOT NULL default '',
 
158
TEX char(70) NOT NULL default '',
 
159
PRIMARY KEY  (t1ID),
 
160
KEY IdxArt (art),
 
161
KEY IdxKnr (KNR),
 
162
KEY IdxArtnr (ARTNR)
 
163
) ENGINE=MyISAM;
 
164
INSERT INTO t1 (art) VALUES ('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),
 
165
('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),
 
166
('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),
 
167
('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),
 
168
('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),
 
169
('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),
 
170
('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),
 
171
('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),
 
172
('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),
 
173
('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),
 
174
('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),
 
175
('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),
 
176
('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),
 
177
('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),
 
178
('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),
 
179
('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),
 
180
('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),
 
181
('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),
 
182
('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),
 
183
('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),
 
184
('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),
 
185
('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),
 
186
('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),
 
187
('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),
 
188
('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),
 
189
('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),
 
190
('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),
 
191
('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),
 
192
('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),
 
193
('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),
 
194
('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),
 
195
('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),
 
196
('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),
 
197
('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),
 
198
('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),
 
199
('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),
 
200
('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),
 
201
('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j');
 
202
select count(*) from t1 where upper(art) = 'J';
 
203
count(*)
 
204
213
 
205
select count(*) from t1 where art = 'J' or art = 'j';
 
206
count(*)
 
207
602
 
208
select count(*) from t1 where art = 'j' or art = 'J';
 
209
count(*)
 
210
602
 
211
select count(*) from t1 where art = 'j';
 
212
count(*)
 
213
389
 
214
select count(*) from t1 where art = 'J';
 
215
count(*)
 
216
213
 
217
drop table t1;
 
218
create table t1 (x int, y int, index(x), index(y));
 
219
insert into t1 (x) values (1),(2),(3),(4),(5),(6),(7),(8),(9);
 
220
update t1 set y=x;
 
221
explain select * from t1, t1 t2 where t1.y = 8 and t2.x between 7 and t1.y+0;
 
222
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
223
1       SIMPLE  t1      ref     y       y       5       const   1       
 
224
1       SIMPLE  t2      range   x       x       5       NULL    1       Using where; Using join buffer
 
225
explain select * from t1, t1 t2 where t1.y = 8 and t2.x >= 7 and t2.x <= t1.y+0;
 
226
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
227
1       SIMPLE  t1      ref     y       y       5       const   1       
 
228
1       SIMPLE  t2      range   x       x       5       NULL    1       Using where; Using join buffer
 
229
explain select * from t1, t1 t2 where t1.y = 2 and t2.x between t1.y-1 and t1.y+1;
 
230
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
231
1       SIMPLE  t1      ref     y       y       5       const   1       
 
232
1       SIMPLE  t2      range   x       x       5       NULL    1       Using where; Using join buffer
 
233
explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= t1.y-1 and t2.x <= t1.y+1;
 
234
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
235
1       SIMPLE  t1      ref     y       y       5       const   1       
 
236
1       SIMPLE  t2      range   x       x       5       NULL    1       Using where; Using join buffer
 
237
explain select * from t1, t1 t2 where t1.y = 2 and t2.x between 0 and t1.y;
 
238
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
239
1       SIMPLE  t1      ref     y       y       5       const   1       
 
240
1       SIMPLE  t2      range   x       x       5       NULL    1       Using where; Using join buffer
 
241
explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= 0 and t2.x <= t1.y;
 
242
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
243
1       SIMPLE  t1      ref     y       y       5       const   1       
 
244
1       SIMPLE  t2      range   x       x       5       NULL    1       Using where; Using join buffer
 
245
explain select count(*) from t1 where x in (1);
 
246
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
247
1       SIMPLE  t1      ref     x       x       5       const   1       Using index
 
248
explain select count(*) from t1 where x in (1,2);
 
249
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
250
1       SIMPLE  t1      index   x       x       5       NULL    9       Using where; Using index
 
251
drop table t1;
 
252
CREATE TABLE t1 (key1 int NOT NULL default '0', KEY i1 (key1));
 
253
INSERT INTO t1 VALUES (0),(0),(0),(0),(0),(1),(1);
 
254
CREATE TABLE t2 (keya int NOT NULL default '0', KEY j1 (keya));
 
255
INSERT INTO t2 VALUES (0),(0),(1),(1),(2),(2);
 
256
explain select * from t1, t2 where (t1.key1 <t2.keya + 1) and t2.keya=3;
 
257
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
258
1       SIMPLE  t1      range   i1      i1      4       NULL    1       Using where; Using index
 
259
1       SIMPLE  t2      ref     j1      j1      4       const   1       Using index
 
260
explain select * from t1 force index(i1), t2 force index(j1) where 
 
261
(t1.key1 <t2.keya + 1) and t2.keya=3;
 
262
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
263
1       SIMPLE  t1      range   i1      i1      4       NULL    1       Using where; Using index
 
264
1       SIMPLE  t2      ref     j1      j1      4       const   1       Using index
 
265
DROP TABLE t1,t2;
 
266
CREATE TABLE t1 (
 
267
a int default NULL,
 
268
b int default NULL,
 
269
KEY a (a),
 
270
KEY b (b)
 
271
) ENGINE=MyISAM;
 
272
INSERT INTO t1 VALUES
 
273
(1,1),(2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1),(10,2),(10,2),
 
274
(13,2),(14,2),(15,2),(16,2),(17,3),(17,3),(16,3),(17,3),(19,3),(20,3),
 
275
(21,4),(22,5),(23,5),(24,5),(25,5),(26,5),(30,5),(31,5),(32,5),(33,5),
 
276
(33,5),(33,5),(33,5),(33,5),(34,5),(35,5);
 
277
EXPLAIN SELECT * FROM t1 WHERE a IN(1,2) AND b=5;
 
278
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
279
1       SIMPLE  t1      range   a,b     a       5       NULL    2       Using where; Using MRR
 
280
SELECT * FROM t1 WHERE a IN(1,2) AND b=5;
 
281
a       b
 
282
DROP TABLE t1;
 
283
CREATE TABLE t1 (a int, b int, c int, INDEX (c,a,b));
 
284
INSERT INTO t1 VALUES (1,0,0),(1,0,0),(1,0,0);
 
285
INSERT INTO t1 VALUES (0,1,0),(0,1,0),(0,1,0);
 
286
SELECT COUNT(*) FROM t1 WHERE (c=0 and a=1) or (c=0 and b=1);
 
287
COUNT(*)
 
288
6
 
289
SELECT COUNT(*) FROM t1 WHERE (c=0 and b=1) or (c=0 and a=1);
 
290
COUNT(*)
 
291
6
 
292
DROP TABLE t1;
 
293
CREATE TABLE t1 ( a int not null, b int not null, INDEX ab(a,b) );
 
294
INSERT INTO t1 VALUES (47,1), (70,1), (15,1), (15, 4);
 
295
SELECT * FROM t1
 
296
WHERE
 
297
(
 
298
( b =1 AND a BETWEEN 14 AND 21 ) OR
 
299
( b =2 AND a BETWEEN 16 AND 18 ) OR
 
300
( b =3 AND a BETWEEN 15 AND 19 ) OR
 
301
(a BETWEEN 19 AND 47)
 
302
);
 
303
a       b
 
304
15      1
 
305
47      1
 
306
DROP TABLE t1;
 
307
CREATE TABLE t1 (
 
308
id int NOT NULL AUTO_INCREMENT ,
 
309
line int NOT NULL default '0',
 
310
columnid int NOT NULL default '0',
 
311
owner int NOT NULL default '0',
 
312
ordinal int NOT NULL default '0',
 
313
showid int NOT NULL default '1',
 
314
tableid int NOT NULL default '1',
 
315
content int NOT NULL default '188',
 
316
PRIMARY KEY ( owner, id ) ,
 
317
KEY menu( owner, showid, columnid ) ,
 
318
KEY `COLUMN` ( owner, columnid, line ) ,
 
319
KEY `LINES` ( owner, tableid, content, id ) ,
 
320
KEY recount( owner, line ) 
 
321
) ENGINE = MYISAM;
 
322
INSERT into t1 (owner,id,columnid,line) values (11,15,15,1),(11,13,13,5);
 
323
SELECT id, columnid, tableid, content, showid, line, ordinal FROM t1 WHERE owner=11 AND ((columnid IN ( 15, 13, 14 ) AND line IN ( 1, 2, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 31 )) OR (columnid IN ( 13, 14 ) AND line IN ( 15 ))) LIMIT 0 , 30;
 
324
id      columnid        tableid content showid  line    ordinal
 
325
13      13      1       188     1       5       0
 
326
15      15      1       188     1       1       0
 
327
drop table t1;
 
328
create  table t1 (id int primary key);
 
329
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9);
 
330
select id from t1 where id in (2,5,9) ;
 
331
id
 
332
2
 
333
5
 
334
9
 
335
select id from t1 where id=2 or id=5 or id=9 ;
 
336
id
 
337
2
 
338
5
 
339
9
 
340
drop table t1;
 
341
create table t1 ( id1 int not null, id2 int not null, idnull int null, c char(20), primary key (id1,id2));
 
342
insert into t1 values (0,1,NULL,"aaa"), (1,1,NULL,"aaa"), (2,1,NULL,"aaa"),
 
343
(3,1,NULL,"aaa"), (4,1,NULL,"aaa"), (5,1,NULL,"aaa"),
 
344
(6,1,NULL,"aaa"), (7,1,NULL,"aaa"), (8,1,NULL,"aaa"),
 
345
(9,1,NULL,"aaa"), (10,1,NULL,"aaa"), (11,1,NULL,"aaa"),
 
346
(12,1,NULL,"aaa"), (13,1,NULL,"aaa"), (14,1,NULL,"aaa"),
 
347
(15,1,NULL,"aaa"), (16,1,NULL,"aaa"), (17,1,NULL,"aaa"),
 
348
(18,1,NULL,"aaa"), (19,1,NULL,"aaa"), (20,1,NULL,"aaa");
 
349
select a.id1, b.idnull from t1 as a, t1 as b where a.id2=1 and a.id1=1 and b.id1=a.idnull order by b.id2 desc limit 1;
 
350
id1     idnull
 
351
drop table t1;
 
352
create table t1 (
 
353
id int not null auto_increment,
 
354
name char(1) not null,
 
355
uid int not null,
 
356
primary key (id),
 
357
index uid_index (uid)) ENGINE=Myisam;
 
358
create table t2 (
 
359
id int not null auto_increment,
 
360
name char(1) not null,
 
361
uid int not null,
 
362
primary key (id),
 
363
index uid_index (uid)) engine=myisam;
 
364
insert into t1(id, uid, name) values(1, 0, ' ');
 
365
insert into t1(uid, name) values(0, ' ');
 
366
insert into t2(uid, name) select uid, name from t1;
 
367
insert into t1(uid, name) select uid, name from t2;
 
368
insert into t2(uid, name) select uid, name from t1;
 
369
insert into t1(uid, name) select uid, name from t2;
 
370
insert into t2(uid, name) select uid, name from t1;
 
371
insert into t1(uid, name) select uid, name from t2;
 
372
insert into t2(uid, name) select uid, name from t1;
 
373
insert into t1(uid, name) select uid, name from t2;
 
374
insert into t2(uid, name) select uid, name from t1;
 
375
insert into t1(uid, name) select uid, name from t2;
 
376
insert into t2(uid, name) select uid, name from t1;
 
377
insert into t2(uid, name) select uid, name from t1;
 
378
insert into t2(uid, name) select uid, name from t1;
 
379
insert into t2(uid, name) select uid, name from t1;
 
380
insert into t1(uid, name) select uid, name from t2;
 
381
delete from t2;
 
382
insert into t2(uid, name) values 
 
383
(1, CHAR(64+1)),
 
384
(2, CHAR(64+2)),
 
385
(3, CHAR(64+3)),
 
386
(4, CHAR(64+4)),
 
387
(5, CHAR(64+5)),
 
388
(6, CHAR(64+6)),
 
389
(7, CHAR(64+7)),
 
390
(8, CHAR(64+8)),
 
391
(9, CHAR(64+9)),
 
392
(10, CHAR(64+10)),
 
393
(11, CHAR(64+11)),
 
394
(12, CHAR(64+12)),
 
395
(13, CHAR(64+13)),
 
396
(14, CHAR(64+14)),
 
397
(15, CHAR(64+15)),
 
398
(16, CHAR(64+16)),
 
399
(17, CHAR(64+17)),
 
400
(18, CHAR(64+18)),
 
401
(19, CHAR(64+19)),
 
402
(20, CHAR(64+20)),
 
403
(21, CHAR(64+21)),
 
404
(22, CHAR(64+22)),
 
405
(23, CHAR(64+23)),
 
406
(24, CHAR(64+24)),
 
407
(25, CHAR(64+25)),
 
408
(26, CHAR(64+26));
 
409
insert into t1(uid, name) select uid, name from t2 order by uid;
 
410
delete from t2;
 
411
insert into t2(id, uid, name) select id, uid, name from t1;
 
412
select count(*) from t1;
 
413
count(*)
 
414
1026
 
415
select count(*) from t2;
 
416
count(*)
 
417
1026
 
418
analyze table t1,t2;
 
419
Table   Op      Msg_type        Msg_text
 
420
test.t1 analyze status  OK
 
421
test.t2 analyze status  Table is already up to date
 
422
explain select * from t1, t2  where t1.uid=t2.uid AND t1.uid > 0;
 
423
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
424
1       SIMPLE  t1      range   uid_index       uid_index       4       NULL    112     Using where; Using MRR
 
425
1       SIMPLE  t2      ref     uid_index       uid_index       4       test.t1.uid     38      
 
426
explain select * from t1, t2  where t1.uid=t2.uid AND t2.uid > 0;
 
427
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
428
1       SIMPLE  t1      range   uid_index       uid_index       4       NULL    112     Using where; Using MRR
 
429
1       SIMPLE  t2      ref     uid_index       uid_index       4       test.t1.uid     38      
 
430
explain select * from t1, t2  where t1.uid=t2.uid AND t1.uid != 0;
 
431
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
432
1       SIMPLE  t1      range   uid_index       uid_index       4       NULL    113     Using where; Using MRR
 
433
1       SIMPLE  t2      ref     uid_index       uid_index       4       test.t1.uid     38      
 
434
explain select * from t1, t2  where t1.uid=t2.uid AND t2.uid != 0;
 
435
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
436
1       SIMPLE  t1      range   uid_index       uid_index       4       NULL    113     Using where; Using MRR
 
437
1       SIMPLE  t2      ref     uid_index       uid_index       4       test.t1.uid     38      
 
438
select * from t1, t2  where t1.uid=t2.uid AND t1.uid > 0;
 
439
id      name    uid     id      name    uid
 
440
1001    A       1       1001    A       1
 
441
1002    B       2       1002    B       2
 
442
1003    C       3       1003    C       3
 
443
1004    D       4       1004    D       4
 
444
1005    E       5       1005    E       5
 
445
1006    F       6       1006    F       6
 
446
1007    G       7       1007    G       7
 
447
1008    H       8       1008    H       8
 
448
1009    I       9       1009    I       9
 
449
1010    J       10      1010    J       10
 
450
1011    K       11      1011    K       11
 
451
1012    L       12      1012    L       12
 
452
1013    M       13      1013    M       13
 
453
1014    N       14      1014    N       14
 
454
1015    O       15      1015    O       15
 
455
1016    P       16      1016    P       16
 
456
1017    Q       17      1017    Q       17
 
457
1018    R       18      1018    R       18
 
458
1019    S       19      1019    S       19
 
459
1020    T       20      1020    T       20
 
460
1021    U       21      1021    U       21
 
461
1022    V       22      1022    V       22
 
462
1023    W       23      1023    W       23
 
463
1024    X       24      1024    X       24
 
464
1025    Y       25      1025    Y       25
 
465
1026    Z       26      1026    Z       26
 
466
select * from t1, t2  where t1.uid=t2.uid AND t1.uid != 0;
 
467
id      name    uid     id      name    uid
 
468
1001    A       1       1001    A       1
 
469
1002    B       2       1002    B       2
 
470
1003    C       3       1003    C       3
 
471
1004    D       4       1004    D       4
 
472
1005    E       5       1005    E       5
 
473
1006    F       6       1006    F       6
 
474
1007    G       7       1007    G       7
 
475
1008    H       8       1008    H       8
 
476
1009    I       9       1009    I       9
 
477
1010    J       10      1010    J       10
 
478
1011    K       11      1011    K       11
 
479
1012    L       12      1012    L       12
 
480
1013    M       13      1013    M       13
 
481
1014    N       14      1014    N       14
 
482
1015    O       15      1015    O       15
 
483
1016    P       16      1016    P       16
 
484
1017    Q       17      1017    Q       17
 
485
1018    R       18      1018    R       18
 
486
1019    S       19      1019    S       19
 
487
1020    T       20      1020    T       20
 
488
1021    U       21      1021    U       21
 
489
1022    V       22      1022    V       22
 
490
1023    W       23      1023    W       23
 
491
1024    X       24      1024    X       24
 
492
1025    Y       25      1025    Y       25
 
493
1026    Z       26      1026    Z       26
 
494
drop table t1,t2;
 
495
create table t1 (x bigint not null);
 
496
insert into t1(x) values (0x0ffffffffffffff0);
 
497
insert into t1(x) values (0x0ffffffffffffff1);
 
498
select * from t1;
 
499
x
 
500
1152921504606846960
 
501
1152921504606846961
 
502
select count(*) from t1 where x>0;
 
503
count(*)
 
504
2
 
505
select count(*) from t1 where x=0;
 
506
count(*)
 
507
0
 
508
select count(*) from t1 where x<0;
 
509
count(*)
 
510
0
 
511
select count(*) from t1 where x < -16;
 
512
count(*)
 
513
0
 
514
select count(*) from t1 where x = -16;
 
515
count(*)
 
516
0
 
517
select count(*) from t1 where x > -16;
 
518
count(*)
 
519
2
 
520
select count(*) from t1 where x = 18446744073709551601;
 
521
count(*)
 
522
0
 
523
create table t2 (x bigint not null);
 
524
insert into t2(x) values (-16);
 
525
insert into t2(x) values (-15);
 
526
select * from t2;
 
527
x
 
528
-16
 
529
-15
 
530
select count(*) from t2 where x>0;
 
531
count(*)
 
532
0
 
533
select count(*) from t2 where x=0;
 
534
count(*)
 
535
0
 
536
select count(*) from t2 where x<0;
 
537
count(*)
 
538
2
 
539
select count(*) from t2 where x < -16;
 
540
count(*)
 
541
0
 
542
select count(*) from t2 where x = -16;
 
543
count(*)
 
544
1
 
545
select count(*) from t2 where x > -16;
 
546
count(*)
 
547
1
 
548
select count(*) from t2 where x = 18446744073709551601;
 
549
count(*)
 
550
1
 
551
drop table t1,t2;
 
552
create table t1 (x bigint not null primary key) engine=innodb;
 
553
insert into t1(x) values (0x0ffffffffffffff0);
 
554
insert into t1(x) values (0x0ffffffffffffff1);
 
555
select * from t1;
 
556
x
 
557
1152921504606846960
 
558
1152921504606846961
 
559
select count(*) from t1 where x>0;
 
560
count(*)
 
561
2
 
562
select count(*) from t1 where x=0;
 
563
count(*)
 
564
0
 
565
select count(*) from t1 where x<0;
 
566
count(*)
 
567
0
 
568
select count(*) from t1 where x < -16;
 
569
count(*)
 
570
0
 
571
select count(*) from t1 where x = -16;
 
572
count(*)
 
573
0
 
574
select count(*) from t1 where x > -16;
 
575
count(*)
 
576
2
 
577
select count(*) from t1 where x = 18446744073709551601;
 
578
count(*)
 
579
0
 
580
drop table t1;
 
581
create table t1 (a bigint);
 
582
create index t1i on t1(a);
 
583
insert into t1 select 18446744073709551615;
 
584
insert into t1 select 18446744073709551614;
 
585
explain select * from t1 where a <> -1;
 
586
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
587
1       SIMPLE  t1      index   t1i     t1i     9       NULL    2       Using where; Using index
 
588
select * from t1 where a <> -1;
 
589
a
 
590
-2
 
591
explain select * from t1 where a > -1 or a < -1;
 
592
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
593
1       SIMPLE  t1      index   t1i     t1i     9       NULL    2       Using where; Using index
 
594
select * from t1 where a > -1 or a < -1;
 
595
a
 
596
-2
 
597
explain select * from t1 where a > -1;
 
598
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
599
1       SIMPLE  t1      index   t1i     t1i     9       NULL    2       Using where; Using index
 
600
select * from t1 where a > -1;
 
601
a
 
602
explain select * from t1 where a < -1;
 
603
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
604
1       SIMPLE  t1      index   t1i     t1i     9       NULL    2       Using where; Using index
 
605
select * from t1 where a < -1;
 
606
a
 
607
-2
 
608
drop table t1;
 
609
create table t1 (a char(10), b text, key (a));
 
610
INSERT INTO t1 (a) VALUES
 
611
('111'),('222'),('222'),('222'),('222'),('444'),('aaa'),('AAA'),('bbb');
 
612
explain select * from t1 where a='aaa';
 
613
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
614
1       SIMPLE  t1      ref     a       a       43      const   1       Using where
 
615
explain select * from t1 where a=binary 'aaa';
 
616
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
617
1       SIMPLE  t1      range   a       a       43      NULL    1       Using where
 
618
explain select * from t1 where a='aaa' collate utf8_bin;
 
619
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
620
1       SIMPLE  t1      range   a       a       43      NULL    1       Using where
 
621
drop table t1;
 
622
CREATE TABLE t1 (
 
623
`CLIENT` char(3) collate utf8_bin NOT NULL default '000',
 
624
`ARG1` char(3) collate utf8_bin NOT NULL default '',
 
625
`ARG2` char(3) collate utf8_bin NOT NULL default '',
 
626
`FUNCTION` varchar(10) collate utf8_bin NOT NULL default '',
 
627
`FUNCTINT` int NOT NULL default '0',
 
628
KEY `VERI_CLNT~2` (`ARG1`)
 
629
) ENGINE=InnoDB;
 
630
INSERT INTO t1 VALUES ('000',' 0',' 0','Text 001',0), ('000',' 0',' 1','Text 002',0),
 
631
('000',' 1',' 2','Text 003',0), ('000',' 2',' 3','Text 004',0),
 
632
('001',' 3',' 0','Text 017',0);
 
633
SELECT count(*) FROM t1 WHERE CLIENT='000' AND (ARG1 != ' 1' OR ARG1 != ' 2');
 
634
count(*)
 
635
4
 
636
SELECT count(*) FROM t1 WHERE CLIENT='000' AND (ARG1 != ' 2' OR ARG1 != ' 1');
 
637
count(*)
 
638
4
 
639
drop table t1;
 
640
create table t1 (a int);
 
641
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
 
642
CREATE TABLE t2 (
 
643
pk1 int NOT NULL,
 
644
pk2 int NOT NULL,
 
645
pk3 int NOT NULL,
 
646
pk4 int NOT NULL,
 
647
filler char(82),
 
648
PRIMARY KEY (pk1,pk2,pk3,pk4)
 
649
);
 
650
insert into t2 select 1, A.a+10*B.a, 432, 44, 'fillerZ' from t1 A, t1 B;
 
651
INSERT INTO t2 VALUES (2621, 2635, 0, 0,'filler'), (2621, 2635, 1, 0,'filler'),
 
652
(2621, 2635, 10, 0,'filler'), (2621, 2635, 11, 0,'filler'),
 
653
(2621, 2635, 14, 0,'filler'), (2621, 2635, 1000015, 0,'filler');
 
654
SELECT * FROM t2
 
655
WHERE ((((pk4 =0) AND (pk1 =2621) AND (pk2 =2635)))
 
656
OR ((pk4 =1) AND (((pk1 IN ( 7, 2, 1 ))) OR (pk1 =522)) AND ((pk2 IN ( 0, 2635))))
 
657
) AND (pk3 >=1000000);
 
658
pk1     pk2     pk3     pk4     filler
 
659
2621    2635    1000015 0       filler
 
660
drop table t1, t2;
 
661
create table t1(a char(2), key(a(1)));
 
662
insert into t1 values ('x'), ('xx');
 
663
explain select a from t1 where a > 'x';
 
664
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
665
1       SIMPLE  t1      range   a       a       7       NULL    1       Using where
 
666
select a from t1 where a > 'x';
 
667
a
 
668
xx
 
669
drop table t1;
 
670
CREATE TABLE t1 (
 
671
OXID varchar(32) NOT NULL DEFAULT '',
 
672
OXPARENTID varchar(32) NOT NULL DEFAULT 'oxrootid',
 
673
OXLEFT int NOT NULL DEFAULT '0',
 
674
OXRIGHT int NOT NULL DEFAULT '0',
 
675
OXROOTID varchar(32) NOT NULL DEFAULT '',
 
676
PRIMARY KEY  (OXID),
 
677
KEY OXNID (OXID),
 
678
KEY OXLEFT (OXLEFT),
 
679
KEY OXRIGHT (OXRIGHT),
 
680
KEY OXROOTID (OXROOTID)
 
681
) ENGINE=MyISAM;
 
682
INSERT INTO t1 VALUES
 
683
('d8c4177d09f8b11f5.52725521','oxrootid',1,40,'d8c4177d09f8b11f5.52725521'),
 
684
('d8c4177d151affab2.81582770','d8c4177d09f8b11f5.52725521',2,3,
 
685
'd8c4177d09f8b11f5.52725521'),
 
686
('d8c4177d206a333d2.74422679','d8c4177d09f8b11f5.52725521',4,5,
 
687
'd8c4177d09f8b11f5.52725521'),
 
688
('d8c4177d225791924.30714720','d8c4177d09f8b11f5.52725521',6,7,
 
689
'd8c4177d09f8b11f5.52725521'),
 
690
('d8c4177d2380fc201.39666693','d8c4177d09f8b11f5.52725521',8,9,
 
691
'd8c4177d09f8b11f5.52725521'),
 
692
('d8c4177d24ccef970.14957924','d8c4177d09f8b11f5.52725521',10,11,
 
693
'd8c4177d09f8b11f5.52725521');
 
694
EXPLAIN
 
695
SELECT s.oxid FROM t1 v, t1 s 
 
696
WHERE s.oxrootid = 'd8c4177d09f8b11f5.52725521' AND
 
697
v.oxrootid ='d8c4177d09f8b11f5.52725521' AND
 
698
s.oxleft > v.oxleft AND s.oxleft < v.oxright;
 
699
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
700
1       SIMPLE  v       ref     OXLEFT,OXRIGHT,OXROOTID OXROOTID        130     const   5       Using where
 
701
1       SIMPLE  s       ALL     OXLEFT  NULL    NULL    NULL    6       Range checked for each record (index map: 0x4)
 
702
SELECT s.oxid FROM t1 v, t1 s 
 
703
WHERE s.oxrootid = 'd8c4177d09f8b11f5.52725521' AND
 
704
v.oxrootid ='d8c4177d09f8b11f5.52725521' AND
 
705
s.oxleft > v.oxleft AND s.oxleft < v.oxright;
 
706
oxid
 
707
d8c4177d151affab2.81582770
 
708
d8c4177d206a333d2.74422679
 
709
d8c4177d225791924.30714720
 
710
d8c4177d2380fc201.39666693
 
711
d8c4177d24ccef970.14957924
 
712
DROP TABLE t1;
 
713
create table t1 (
 
714
c1  char(10), c2  char(10), c3  char(10), c4  char(10),
 
715
c5  char(10), c6  char(10), c7  char(10), c8  char(10),
 
716
c9  char(10), c10 char(10), c11 char(10), c12 char(10),
 
717
c13 char(10), c14 char(10), c15 char(10), c16 char(10),
 
718
index(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12,c13,c14,c15,c16)
 
719
);
 
720
insert into t1 (c1) values ('1'),('1'),('1'),('1');
 
721
select * from t1 where
 
722
c1 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", 
 
723
"abcdefg1", "123456781", "qwertyui1", "asddfg1", 
 
724
"abcdefg2", "123456782", "qwertyui2", "asddfg2", 
 
725
"abcdefg3", "123456783", "qwertyui3", "asddfg3", 
 
726
"abcdefg4", "123456784", "qwertyui4", "asddfg4",
 
727
"abcdefg5", "123456785", "qwertyui5", "asddfg5",
 
728
"abcdefg6", "123456786", "qwertyui6", "asddfg6",
 
729
"abcdefg7", "123456787", "qwertyui7", "asddfg7",
 
730
"abcdefg8", "123456788", "qwertyui8", "asddfg8",
 
731
"abcdefg9", "123456789", "qwertyui9", "asddfg9",
 
732
"abcdefgA", "12345678A", "qwertyuiA", "asddfgA",
 
733
"abcdefgB", "12345678B", "qwertyuiB", "asddfgB",
 
734
"abcdefgC", "12345678C", "qwertyuiC", "asddfgC")
 
735
and c2 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", 
 
736
"abcdefg1", "123456781", "qwertyui1", "asddfg1", 
 
737
"abcdefg2", "123456782", "qwertyui2", "asddfg2", 
 
738
"abcdefg3", "123456783", "qwertyui3", "asddfg3", 
 
739
"abcdefg4", "123456784", "qwertyui4", "asddfg4", 
 
740
"abcdefg5", "123456785", "qwertyui5", "asddfg5",
 
741
"abcdefg6", "123456786", "qwertyui6", "asddfg6",
 
742
"abcdefg7", "123456787", "qwertyui7", "asddfg7",
 
743
"abcdefg8", "123456788", "qwertyui8", "asddfg8",
 
744
"abcdefg9", "123456789", "qwertyui9", "asddfg9",
 
745
"abcdefgA", "12345678A", "qwertyuiA", "asddfgA",
 
746
"abcdefgB", "12345678B", "qwertyuiB", "asddfgB",
 
747
"abcdefgC", "12345678C", "qwertyuiC", "asddfgC")
 
748
and c3 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", 
 
749
"abcdefg1", "123456781", "qwertyui1", "asddfg1", 
 
750
"abcdefg2", "123456782", "qwertyui2", "asddfg2", 
 
751
"abcdefg3", "123456783", "qwertyui3", "asddfg3", 
 
752
"abcdefg4", "123456784", "qwertyui4", "asddfg4", 
 
753
"abcdefg5", "123456785", "qwertyui5", "asddfg5",
 
754
"abcdefg6", "123456786", "qwertyui6", "asddfg6",
 
755
"abcdefg7", "123456787", "qwertyui7", "asddfg7",
 
756
"abcdefg8", "123456788", "qwertyui8", "asddfg8",
 
757
"abcdefg9", "123456789", "qwertyui9", "asddfg9",
 
758
"abcdefgA", "12345678A", "qwertyuiA", "asddfgA",
 
759
"abcdefgB", "12345678B", "qwertyuiB", "asddfgB",
 
760
"abcdefgC", "12345678C", "qwertyuiC", "asddfgC")
 
761
and c4 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", 
 
762
"abcdefg1", "123456781", "qwertyui1", "asddfg1", 
 
763
"abcdefg2", "123456782", "qwertyui2", "asddfg2", 
 
764
"abcdefg3", "123456783", "qwertyui3", "asddfg3", 
 
765
"abcdefg4", "123456784", "qwertyui4", "asddfg4", 
 
766
"abcdefg5", "123456785", "qwertyui5", "asddfg5", 
 
767
"abcdefg6", "123456786", "qwertyui6", "asddfg6",
 
768
"abcdefg7", "123456787", "qwertyui7", "asddfg7",
 
769
"abcdefg8", "123456788", "qwertyui8", "asddfg8",
 
770
"abcdefg9", "123456789", "qwertyui9", "asddfg9",
 
771
"abcdefgA", "12345678A", "qwertyuiA", "asddfgA",
 
772
"abcdefgB", "12345678B", "qwertyuiB", "asddfgB",
 
773
"abcdefgC", "12345678C", "qwertyuiC", "asddfgC")
 
774
and c5 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", 
 
775
"abcdefg1", "123456781", "qwertyui1", "asddfg1", 
 
776
"abcdefg2", "123456782", "qwertyui2", "asddfg2", 
 
777
"abcdefg3", "123456783", "qwertyui3", "asddfg3", 
 
778
"abcdefg4", "123456784", "qwertyui4", "asddfg4",
 
779
"abcdefg5", "123456785", "qwertyui5", "asddfg5",
 
780
"abcdefg6", "123456786", "qwertyui6", "asddfg6",
 
781
"abcdefg7", "123456787", "qwertyui7", "asddfg7",
 
782
"abcdefg8", "123456788", "qwertyui8", "asddfg8",
 
783
"abcdefg9", "123456789", "qwertyui9", "asddfg9",
 
784
"abcdefgA", "12345678A", "qwertyuiA", "asddfgA",
 
785
"abcdefgB", "12345678B", "qwertyuiB", "asddfgB",
 
786
"abcdefgC", "12345678C", "qwertyuiC", "asddfgC")
 
787
and c6 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", 
 
788
"abcdefg1", "123456781", "qwertyui1", "asddfg1", 
 
789
"abcdefg2", "123456782", "qwertyui2", "asddfg2", 
 
790
"abcdefg3", "123456783", "qwertyui3", "asddfg3", 
 
791
"abcdefg4", "123456784", "qwertyui4", "asddfg4",
 
792
"abcdefg5", "123456785", "qwertyui5", "asddfg5",
 
793
"abcdefg6", "123456786", "qwertyui6", "asddfg6",
 
794
"abcdefg7", "123456787", "qwertyui7", "asddfg7",
 
795
"abcdefg8", "123456788", "qwertyui8", "asddfg8",
 
796
"abcdefg9", "123456789", "qwertyui9", "asddfg9",
 
797
"abcdefgA", "12345678A", "qwertyuiA", "asddfgA",
 
798
"abcdefgB", "12345678B", "qwertyuiB", "asddfgB",
 
799
"abcdefgC", "12345678C", "qwertyuiC", "asddfgC")
 
800
and c7 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", 
 
801
"abcdefg1", "123456781", "qwertyui1", "asddfg1", 
 
802
"abcdefg2", "123456782", "qwertyui2", "asddfg2", 
 
803
"abcdefg3", "123456783", "qwertyui3", "asddfg3", 
 
804
"abcdefg4", "123456784", "qwertyui4", "asddfg4", 
 
805
"abcdefg5", "123456785", "qwertyui5", "asddfg5",
 
806
"abcdefg6", "123456786", "qwertyui6", "asddfg6",
 
807
"abcdefg7", "123456787", "qwertyui7", "asddfg7",
 
808
"abcdefg8", "123456788", "qwertyui8", "asddfg8",
 
809
"abcdefg9", "123456789", "qwertyui9", "asddfg9",
 
810
"abcdefgA", "12345678A", "qwertyuiA", "asddfgA",
 
811
"abcdefgB", "12345678B", "qwertyuiB", "asddfgB",
 
812
"abcdefgC", "12345678C", "qwertyuiC", "asddfgC")
 
813
and c8 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", 
 
814
"abcdefg1", "123456781", "qwertyui1", "asddfg1", 
 
815
"abcdefg2", "123456782", "qwertyui2", "asddfg2", 
 
816
"abcdefg3", "123456783", "qwertyui3", "asddfg3", 
 
817
"abcdefg4", "123456784", "qwertyui4", "asddfg4", 
 
818
"abcdefg5", "123456785", "qwertyui5", "asddfg5",
 
819
"abcdefg6", "123456786", "qwertyui6", "asddfg6",
 
820
"abcdefg7", "123456787", "qwertyui7", "asddfg7",
 
821
"abcdefg8", "123456788", "qwertyui8", "asddfg8",
 
822
"abcdefg9", "123456789", "qwertyui9", "asddfg9",
 
823
"abcdefgA", "12345678A", "qwertyuiA", "asddfgA",
 
824
"abcdefgB", "12345678B", "qwertyuiB", "asddfgB",
 
825
"abcdefgC", "12345678C", "qwertyuiC", "asddfgC")
 
826
and c9 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", 
 
827
"abcdefg1", "123456781", "qwertyui1", "asddfg1", 
 
828
"abcdefg2", "123456782", "qwertyui2", "asddfg2", 
 
829
"abcdefg3", "123456783", "qwertyui3", "asddfg3", 
 
830
"abcdefg4", "123456784", "qwertyui4", "asddfg4", 
 
831
"abcdefg5", "123456785", "qwertyui5", "asddfg5",
 
832
"abcdefg6", "123456786", "qwertyui6", "asddfg6",
 
833
"abcdefg7", "123456787", "qwertyui7", "asddfg7",
 
834
"abcdefg8", "123456788", "qwertyui8", "asddfg8",
 
835
"abcdefg9", "123456789", "qwertyui9", "asddfg9",
 
836
"abcdefgA", "12345678A", "qwertyuiA", "asddfgA",
 
837
"abcdefgB", "12345678B", "qwertyuiB", "asddfgB",
 
838
"abcdefgC", "12345678C", "qwertyuiC", "asddfgC")
 
839
and c10 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", 
 
840
"abcdefg1", "123456781", "qwertyui1", "asddfg1", 
 
841
"abcdefg2", "123456782", "qwertyui2", "asddfg2", 
 
842
"abcdefg3", "123456783", "qwertyui3", "asddfg3", 
 
843
"abcdefg4", "123456784", "qwertyui4", "asddfg4", 
 
844
"abcdefg5", "123456785", "qwertyui5", "asddfg5",
 
845
"abcdefg6", "123456786", "qwertyui6", "asddfg6",
 
846
"abcdefg7", "123456787", "qwertyui7", "asddfg7",
 
847
"abcdefg8", "123456788", "qwertyui8", "asddfg8",
 
848
"abcdefg9", "123456789", "qwertyui9", "asddfg9",
 
849
"abcdefgA", "12345678A", "qwertyuiA", "asddfgA",
 
850
"abcdefgB", "12345678B", "qwertyuiB", "asddfgB",
 
851
"abcdefgC", "12345678C", "qwertyuiC", "asddfgC");
 
852
c1      c2      c3      c4      c5      c6      c7      c8      c9      c10     c11     c12     c13     c14     c15     c16
 
853
drop table t1;
 
854
End of 4.1 tests
 
855
CREATE TABLE t1 (
 
856
id int NOT NULL auto_increment,
 
857
status varchar(20),
 
858
PRIMARY KEY  (id),
 
859
KEY (status)
 
860
);
 
861
INSERT INTO t1 VALUES
 
862
(1,'B'), (2,'B'), (3,'B'), (4,'B'), (5,'B'), (6,'B'),
 
863
(7,'B'), (8,'B'), (9,'B'), (10,'B'), (11,'B'), (12,'B'),
 
864
(13,'B'), (14,'B'), (15,'B'), (16,'B'), (17,'B'), (18,'B'),
 
865
(19,'B'), (20,'B'), (21,'B'), (22,'B'), (23,'B'), (24,'B'), 
 
866
(25,'A'), (26,'A'), (27,'A'), (28,'A'), (29,'A'), (30,'A'),
 
867
(31,'A'), (32,'A'), (33,'A'), (34,'A'), (35,'A'), (36,'A'),
 
868
(37,'A'), (38,'A'), (39,'A'), (40,'A'), (41,'A'), (42,'A'),
 
869
(43,'A'), (44,'A'), (45,'A'), (46,'A'), (47,'A'), (48,'A'),
 
870
(49,'A'), (50,'A'), (51,'A'), (52,'A'), (53,'C'), (54,'C'),
 
871
(55,'C'), (56,'C'), (57,'C'), (58,'C'), (59,'C'), (60,'C');
 
872
EXPLAIN SELECT * FROM t1 WHERE status <> 'A' AND status <> 'B';
 
873
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
874
1       SIMPLE  t1      range   status  status  83      NULL    3       Using where
 
875
EXPLAIN SELECT * FROM t1 WHERE status NOT IN ('A','B');
 
876
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
877
1       SIMPLE  t1      range   status  status  83      NULL    3       Using where
 
878
SELECT * FROM t1 WHERE status <> 'A' AND status <> 'B';
 
879
id      status
 
880
53      C
 
881
54      C
 
882
55      C
 
883
56      C
 
884
57      C
 
885
58      C
 
886
59      C
 
887
60      C
 
888
SELECT * FROM t1 WHERE status NOT IN ('A','B');
 
889
id      status
 
890
53      C
 
891
54      C
 
892
55      C
 
893
56      C
 
894
57      C
 
895
58      C
 
896
59      C
 
897
60      C
 
898
EXPLAIN SELECT status FROM t1 WHERE status <> 'A' AND status <> 'B';
 
899
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
900
1       SIMPLE  t1      range   status  status  83      NULL    3       Using where; Using index
 
901
EXPLAIN SELECT status FROM t1 WHERE status NOT IN ('A','B');
 
902
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
903
1       SIMPLE  t1      range   status  status  83      NULL    3       Using where; Using index
 
904
EXPLAIN SELECT * FROM t1 WHERE status NOT BETWEEN 'A' AND 'B';
 
905
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
906
1       SIMPLE  t1      range   status  status  83      NULL    2       Using where
 
907
EXPLAIN SELECT * FROM t1 WHERE status < 'A' OR status > 'B';
 
908
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
909
1       SIMPLE  t1      range   status  status  83      NULL    2       Using where
 
910
SELECT * FROM t1 WHERE status NOT BETWEEN 'A' AND 'B';
 
911
id      status
 
912
53      C
 
913
54      C
 
914
55      C
 
915
56      C
 
916
57      C
 
917
58      C
 
918
59      C
 
919
60      C
 
920
SELECT * FROM t1 WHERE status < 'A' OR status > 'B';
 
921
id      status
 
922
53      C
 
923
54      C
 
924
55      C
 
925
56      C
 
926
57      C
 
927
58      C
 
928
59      C
 
929
60      C
 
930
DROP TABLE t1;
 
931
CREATE TABLE t1 (name varchar(15) NOT NULL, KEY idx(name));
 
932
INSERT INTO t1 VALUES ('Betty'), ('Anna');
 
933
SELECT * FROM t1;
 
934
name
 
935
Anna
 
936
Betty
 
937
DELETE FROM t1 WHERE name NOT LIKE 'A%a';
 
938
SELECT * FROM t1;
 
939
name
 
940
Anna
 
941
DROP TABLE t1;
 
942
CREATE TABLE t1 (a int, KEY idx(a));
 
943
INSERT INTO t1 VALUES (NULL), (1), (2), (3);
 
944
SELECT * FROM t1;
 
945
a
 
946
NULL
 
947
1
 
948
2
 
949
3
 
950
DELETE FROM t1 WHERE NOT(a <=> 2);
 
951
SELECT * FROM t1;
 
952
a
 
953
2
 
954
DROP TABLE t1;
 
955
create table t3 (a int);
 
956
insert into t3 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
 
957
create table t1 (a varchar(10), filler char(200), key(a));
 
958
insert into t1 values ('a','');
 
959
insert into t1 values ('a ','');
 
960
insert into t1 values ('a  ', '');
 
961
insert into t1 select concat('a', 1000 + A.a + 10 * (B.a + 10 * C.a)), ''
 
962
  from t3 A, t3 B, t3 C;
 
963
create table t2 (a varchar(10), filler char(200), key(a));
 
964
insert into t2 select * from t1;
 
965
explain select * from t1 where a between 'a' and 'a ';
 
966
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
967
1       SIMPLE  t1      ref     a       a       43      const   #       Using where
 
968
explain select * from t1 where a = 'a' or a='a ';
 
969
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
970
1       SIMPLE  t1      ref     a       a       43      const   #       Using where
 
971
explain select * from t2 where a between 'a' and 'a ';
 
972
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
973
1       SIMPLE  t2      ref     a       a       43      const   #       Using where
 
974
explain select * from t2 where a = 'a' or a='a ';
 
975
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
976
1       SIMPLE  t2      ref     a       a       43      const   #       Using where
 
977
update t1 set a='b' where a<>'a';
 
978
explain select * from t1 where a not between 'b' and 'b';
 
979
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
980
1       SIMPLE  t1      range   a       a       43      NULL    #       Using where
 
981
select a, hex(filler) from t1 where a not between 'b' and 'b';
 
982
a       hex(filler)
 
983
a       
 
984
a       
 
985
a       
 
986
drop table t1,t2,t3;
 
987
CREATE TABLE t1 (
 
988
id int NOT NULL DEFAULT '0',
 
989
b int NOT NULL DEFAULT '0',
 
990
c int NOT NULL DEFAULT '0', 
 
991
INDEX idx1(b,c), INDEX idx2(c));
 
992
INSERT INTO t1(id) VALUES (1), (2), (3), (4), (5), (6), (7), (8);
 
993
INSERT INTO t1(b,c) VALUES (3,4), (3,4);
 
994
SELECT * FROM t1 WHERE b<=3 AND 3<=c;
 
995
id      b       c
 
996
0       3       4
 
997
0       3       4
 
998
SELECT * FROM t1 WHERE 3 BETWEEN b AND c;
 
999
id      b       c
 
1000
0       3       4
 
1001
0       3       4
 
1002
EXPLAIN  SELECT * FROM t1 WHERE b<=3 AND 3<=c;
 
1003
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1004
1       SIMPLE  t1      range   idx1,idx2       idx1    4       NULL    1       Using where
 
1005
EXPLAIN  SELECT * FROM t1 WHERE 3 BETWEEN b AND c;
 
1006
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1007
1       SIMPLE  t1      range   idx1,idx2       idx1    4       NULL    1       Using where
 
1008
SELECT * FROM t1 WHERE 0 < b OR 0 > c;
 
1009
id      b       c
 
1010
0       3       4
 
1011
0       3       4
 
1012
SELECT * FROM t1 WHERE 0 NOT BETWEEN b AND c;
 
1013
id      b       c
 
1014
0       3       4
 
1015
0       3       4
 
1016
EXPLAIN SELECT * FROM t1 WHERE 0 < b OR 0 > c;
 
1017
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1018
1       SIMPLE  t1      index_merge     idx1,idx2       idx1,idx2       4,4     NULL    2       Using sort_union(idx1,idx2); Using where
 
1019
EXPLAIN SELECT * FROM t1 WHERE 0 NOT BETWEEN b AND c;
 
1020
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1021
1       SIMPLE  t1      index_merge     idx1,idx2       idx1,idx2       4,4     NULL    2       Using sort_union(idx1,idx2); Using where
 
1022
DROP TABLE t1;
 
1023
CREATE TABLE t1 (                                      
 
1024
item char(20) NOT NULL default '',                          
 
1025
started datetime, 
 
1026
price decimal(16,3) NOT NULL default '0.000',                 
 
1027
PRIMARY KEY (item,started)                     
 
1028
) ENGINE=MyISAM;
 
1029
INSERT INTO t1 VALUES
 
1030
('A1','2005-11-01 08:00:00',1000),
 
1031
('A1','2005-11-15 00:00:00',2000),
 
1032
('A1','2005-12-12 08:00:00',3000),
 
1033
('A2','2005-12-01 08:00:00',1000);
 
1034
EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 23:59:59';
 
1035
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1036
1       SIMPLE  t1      range   PRIMARY PRIMARY 90      NULL    1       Using where; Using MRR
 
1037
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 23:59:59';
 
1038
item    started price
 
1039
A1      2005-11-01 08:00:00     1000.000
 
1040
A1      2005-11-15 00:00:00     2000.000
 
1041
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00';
 
1042
item    started price
 
1043
A1      2005-11-01 08:00:00     1000.000
 
1044
A1      2005-11-15 00:00:00     2000.000
 
1045
DROP TABLE t1;
 
1046
 
 
1047
BUG#32198 "Comparison of DATE with DATETIME still not using indexes correctly"
 
1048
 
 
1049
CREATE TABLE t1 (
 
1050
id int NOT NULL auto_increment,
 
1051
dateval date default NULL,
 
1052
PRIMARY KEY  (id),
 
1053
KEY dateval (dateval)
 
1054
) AUTO_INCREMENT=173;
 
1055
INSERT INTO t1 VALUES
 
1056
(1,'2007-01-01'),(2,'2007-01-02'),(3,'2007-01-03'),(4,'2007-01-04'),
 
1057
(5,'2007-01-05'),(6,'2007-01-06'),(7,'2007-01-07'),(8,'2007-01-08'),
 
1058
(9,'2007-01-09'),(10,'2007-01-10'),(11,'2007-01-11');
 
1059
This must use range access:
 
1060
explain select * from t1 where dateval >= '2007-01-01 00:00:00' and dateval <= '2007-01-02 23:59:59';
 
1061
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1062
1       SIMPLE  t1      range   dateval dateval 4       NULL    1       Using where
 
1063
drop table t1;
 
1064
CREATE TABLE t1 (
 
1065
a varchar(32), index (a)
 
1066
) DEFAULT COLLATE=utf8_bin;
 
1067
INSERT INTO t1 VALUES
 
1068
('B'), ('A'), ('A'), ('C'), ('B'), ('A'), ('A');
 
1069
SELECT a FROM t1 WHERE a='b' OR a='B';
 
1070
a
 
1071
B
 
1072
B
 
1073
EXPLAIN SELECT a FROM t1 WHERE a='b' OR a='B';
 
1074
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1075
1       SIMPLE  t1      index   a       a       131     NULL    7       Using where; Using index
 
1076
DROP TABLE t1;
 
1077
CREATE TABLE t1 (f1 int NOT NULL, PRIMARY KEY (f1));
 
1078
INSERT INTO t1 VALUES (127),(254),(0),(1),(255);
 
1079
SELECT COUNT(*) FROM t1 WHERE f1 < 256;
 
1080
COUNT(*)
 
1081
5
 
1082
SELECT COUNT(*) FROM t1 WHERE f1 < 256.0;
 
1083
COUNT(*)
 
1084
5
 
1085
SELECT COUNT(*) FROM t1 WHERE f1 < 255;
 
1086
COUNT(*)
 
1087
4
 
1088
SELECT COUNT(*) FROM t1 WHERE f1 < -1;
 
1089
COUNT(*)
 
1090
0
 
1091
SELECT COUNT(*) FROM t1 WHERE f1 > -1;
 
1092
COUNT(*)
 
1093
5
 
1094
DROP TABLE t1;
 
1095
CREATE TABLE t1 ( f1 int NOT NULL, PRIMARY KEY (f1));
 
1096
INSERT INTO t1 VALUES (127),(126),(0),(-128),(-127);
 
1097
SELECT COUNT(*) FROM t1 WHERE f1 < 128;
 
1098
COUNT(*)
 
1099
5
 
1100
SELECT COUNT(*) FROM t1 WHERE f1 < 128.0;
 
1101
COUNT(*)
 
1102
5
 
1103
SELECT COUNT(*) FROM t1 WHERE f1 < 127;
 
1104
COUNT(*)
 
1105
4
 
1106
SELECT COUNT(*) FROM t1 WHERE f1 > -129;
 
1107
COUNT(*)
 
1108
5
 
1109
SELECT COUNT(*) FROM t1 WHERE f1 > -129.0;
 
1110
COUNT(*)
 
1111
5
 
1112
SELECT COUNT(*) FROM t1 WHERE f1 > -128;
 
1113
COUNT(*)
 
1114
4
 
1115
DROP TABLE t1;
 
1116
create table t1 (a int);
 
1117
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
 
1118
create table t2 (a int, b int, filler char(100)) ENGINE=myisam;
 
1119
insert into t2 select A.a + 10 * (B.a + 10 * C.a), 10, 'filler' from t1 A,
 
1120
t1 B, t1 C where A.a < 5;
 
1121
insert into t2 select 1000, b, 'filler' from t2;
 
1122
alter table t2 add index (a,b);
 
1123
select 'In following EXPLAIN the access method should be ref, #rows~=500 (and not 2)' Z;
 
1124
Z
 
1125
In following EXPLAIN the access method should be ref, #rows~=500 (and not 2)
 
1126
explain select * from t2 where a=1000 and b<11;
 
1127
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1128
1       SIMPLE  t2      ref     a       a       5       const   502     Using where
 
1129
drop table t1, t2;
 
1130
End of 5.1 tests
 
1131
CREATE TABLE t1 (c1 DECIMAL(10,0),INDEX(c1));
 
1132
INSERT INTO t1 VALUES (1),(2),(3);
 
1133
SELECT c1 FROM t1 WHERE c1 >= 'A' GROUP BY 1;
 
1134
c1
 
1135
1
 
1136
2
 
1137
3
 
1138
Warnings:
 
1139
Warning 1366    Incorrect decimal value: 'A' for column 'c1' at row 1
 
1140
Warning 1292    Truncated incorrect DOUBLE value: 'A'
 
1141
Warning 1292    Truncated incorrect DOUBLE value: 'A'
 
1142
Warning 1292    Truncated incorrect DOUBLE value: 'A'
 
1143
DROP TABLE t1;
 
1144
create table t1 (a int,b int,key (b),key (a),key (b,a));
 
1145
insert into t1(a,b) values (1,2),(3,4),(5,6),(7,8);
 
1146
create table t2 (c int);
 
1147
insert into t2(c) values (1),(5),(6),(7),(8);
 
1148
select 1 from (select c from t1,t2 where b >= 1 and a <=> c group by 1 limit 1) as d1;
 
1149
1
 
1150
1
 
1151
drop table t1, t2;