1
by brian
clean slate |
1 |
drop table if exists t1, t2;
|
2 |
select 1 in (1,2,3);
|
|
3 |
1 in (1,2,3)
|
|
4 |
1
|
|
5 |
select 10 in (1,2,3);
|
|
6 |
10 in (1,2,3)
|
|
7 |
0
|
|
8 |
select NULL in (1,2,3);
|
|
9 |
NULL in (1,2,3)
|
|
10 |
NULL
|
|
11 |
select 1 in (1,NULL,3);
|
|
12 |
1 in (1,NULL,3)
|
|
13 |
1
|
|
14 |
select 3 in (1,NULL,3);
|
|
15 |
3 in (1,NULL,3)
|
|
16 |
1
|
|
17 |
select 10 in (1,NULL,3);
|
|
18 |
10 in (1,NULL,3)
|
|
19 |
NULL
|
|
20 |
select 1.5 in (1.5,2.5,3.5);
|
|
21 |
1.5 in (1.5,2.5,3.5)
|
|
22 |
1
|
|
23 |
select 10.5 in (1.5,2.5,3.5);
|
|
24 |
10.5 in (1.5,2.5,3.5)
|
|
25 |
0
|
|
26 |
select NULL in (1.5,2.5,3.5);
|
|
27 |
NULL in (1.5,2.5,3.5)
|
|
28 |
NULL
|
|
29 |
select 1.5 in (1.5,NULL,3.5);
|
|
30 |
1.5 in (1.5,NULL,3.5)
|
|
31 |
1
|
|
32 |
select 3.5 in (1.5,NULL,3.5);
|
|
33 |
3.5 in (1.5,NULL,3.5)
|
|
34 |
1
|
|
35 |
select 10.5 in (1.5,NULL,3.5);
|
|
36 |
10.5 in (1.5,NULL,3.5)
|
|
37 |
NULL
|
|
38 |
CREATE TABLE t1 (a int, b int, c int);
|
|
39 |
insert into t1 values (1,2,3), (1,NULL,3);
|
|
40 |
select 1 in (a,b,c) from t1;
|
|
41 |
1 in (a,b,c)
|
|
42 |
1
|
|
43 |
1
|
|
44 |
select 3 in (a,b,c) from t1;
|
|
45 |
3 in (a,b,c)
|
|
46 |
1
|
|
47 |
1
|
|
48 |
select 10 in (a,b,c) from t1;
|
|
49 |
10 in (a,b,c)
|
|
50 |
0
|
|
51 |
NULL
|
|
52 |
select NULL in (a,b,c) from t1;
|
|
53 |
NULL in (a,b,c)
|
|
54 |
NULL
|
|
55 |
NULL
|
|
56 |
drop table t1;
|
|
57 |
CREATE TABLE t1 (a float, b float, c float);
|
|
58 |
insert into t1 values (1.5,2.5,3.5), (1.5,NULL,3.5);
|
|
59 |
select 1.5 in (a,b,c) from t1;
|
|
60 |
1.5 in (a,b,c)
|
|
61 |
1
|
|
62 |
1
|
|
63 |
select 3.5 in (a,b,c) from t1;
|
|
64 |
3.5 in (a,b,c)
|
|
65 |
1
|
|
66 |
1
|
|
67 |
select 10.5 in (a,b,c) from t1;
|
|
68 |
10.5 in (a,b,c)
|
|
69 |
0
|
|
70 |
NULL
|
|
71 |
drop table t1;
|
|
72 |
CREATE TABLE t1 (a varchar(10), b varchar(10), c varchar(10));
|
|
73 |
insert into t1 values ('A','BC','EFD'), ('A',NULL,'EFD');
|
|
74 |
select 'A' in (a,b,c) from t1;
|
|
75 |
'A' in (a,b,c)
|
|
76 |
1
|
|
77 |
1
|
|
78 |
select 'EFD' in (a,b,c) from t1;
|
|
79 |
'EFD' in (a,b,c)
|
|
80 |
1
|
|
81 |
1
|
|
82 |
select 'XSFGGHF' in (a,b,c) from t1;
|
|
83 |
'XSFGGHF' in (a,b,c)
|
|
84 |
0
|
|
85 |
NULL
|
|
86 |
drop table t1;
|
|
87 |
CREATE TABLE t1 (field char(1));
|
|
88 |
INSERT INTO t1 VALUES ('A'),(NULL);
|
|
89 |
SELECT * from t1 WHERE field IN (NULL);
|
|
90 |
field
|
|
91 |
SELECT * from t1 WHERE field NOT IN (NULL);
|
|
92 |
field
|
|
93 |
SELECT * from t1 where field = field;
|
|
94 |
field
|
|
95 |
A
|
|
96 |
SELECT * from t1 where field <=> field;
|
|
97 |
field
|
|
98 |
A
|
|
99 |
NULL
|
|
100 |
DELETE FROM t1 WHERE field NOT IN (NULL);
|
|
101 |
SELECT * FROM t1;
|
|
102 |
field
|
|
103 |
A
|
|
104 |
NULL
|
|
105 |
drop table t1;
|
|
106 |
create table t1 (id int(10) primary key);
|
|
107 |
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9);
|
|
108 |
select * from t1 where id in (2,5,9);
|
|
109 |
id
|
|
110 |
2
|
|
111 |
5
|
|
112 |
9
|
|
113 |
drop table t1;
|
|
114 |
create table t1 (
|
|
115 |
a char(1) character set latin1 collate latin1_general_ci,
|
|
116 |
b char(1) character set latin1 collate latin1_swedish_ci,
|
|
117 |
c char(1) character set latin1 collate latin1_danish_ci
|
|
118 |
);
|
|
119 |
insert into t1 values ('A','B','C');
|
|
120 |
insert into t1 values ('a','c','c');
|
|
121 |
select * from t1 where a in (b);
|
|
122 |
ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '='
|
|
123 |
select * from t1 where a in (b,c);
|
|
124 |
ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT), (latin1_swedish_ci,IMPLICIT), (latin1_danish_ci,IMPLICIT) for operation ' IN '
|
|
125 |
select * from t1 where 'a' in (a,b,c);
|
|
126 |
ERROR HY000: Illegal mix of collations for operation ' IN '
|
|
127 |
select * from t1 where 'a' in (a);
|
|
128 |
a b c
|
|
129 |
A B C
|
|
130 |
a c c
|
|
131 |
select * from t1 where a in ('a');
|
|
132 |
a b c
|
|
133 |
A B C
|
|
134 |
a c c
|
|
135 |
select * from t1 where 'a' collate latin1_general_ci in (a,b,c);
|
|
136 |
a b c
|
|
137 |
A B C
|
|
138 |
a c c
|
|
139 |
select * from t1 where 'a' collate latin1_bin in (a,b,c);
|
|
140 |
a b c
|
|
141 |
a c c
|
|
142 |
select * from t1 where 'a' in (a,b,c collate latin1_bin);
|
|
143 |
a b c
|
|
144 |
a c c
|
|
145 |
explain extended select * from t1 where 'a' in (a,b,c collate latin1_bin);
|
|
146 |
id select_type table type possible_keys key key_len ref rows filtered Extra
|
|
147 |
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
|
|
148 |
Warnings:
|
|
149 |
Note 1003 select "test"."t1"."a" AS "a","test"."t1"."b" AS "b","test"."t1"."c" AS "c" from "test"."t1" where ('a' in ("test"."t1"."a","test"."t1"."b",("test"."t1"."c" collate latin1_bin)))
|
|
150 |
drop table t1;
|
|
151 |
set names utf8;
|
|
152 |
create table t1 (a char(10) character set utf8 not null);
|
|
153 |
insert into t1 values ('bbbb'),(_koi8r'ÃÃÃÃ'),(_latin1'ÄÄÄÄ');
|
|
154 |
select a from t1 where a in ('bbbb',_koi8r'ÃÃÃÃ',_latin1'ÄÄÄÄ') order by a;
|
|
155 |
a
|
|
156 |
ÃÃÃÃ
|
|
157 |
bbbb
|
|
158 |
ÑÑÑÑ
|
|
159 |
drop table t1;
|
|
160 |
create table t1 (a char(10) character set latin1 not null);
|
|
161 |
insert into t1 values ('a'),('b'),('c');
|
|
162 |
select a from t1 where a IN ('a','b','c') order by a;
|
|
163 |
a
|
|
164 |
a
|
|
165 |
b
|
|
166 |
c
|
|
167 |
drop table t1;
|
|
168 |
set names latin1;
|
|
169 |
select '1.0' in (1,2);
|
|
170 |
'1.0' in (1,2)
|
|
171 |
1
|
|
172 |
select 1 in ('1.0',2);
|
|
173 |
1 in ('1.0',2)
|
|
174 |
1
|
|
175 |
select 1 in (1,'2.0');
|
|
176 |
1 in (1,'2.0')
|
|
177 |
1
|
|
178 |
select 1 in ('1.0',2.0);
|
|
179 |
1 in ('1.0',2.0)
|
|
180 |
1
|
|
181 |
select 1 in (1.0,'2.0');
|
|
182 |
1 in (1.0,'2.0')
|
|
183 |
1
|
|
184 |
select 1 in ('1.1',2);
|
|
185 |
1 in ('1.1',2)
|
|
186 |
0
|
|
187 |
select 1 in ('1.1',2.0);
|
|
188 |
1 in ('1.1',2.0)
|
|
189 |
0
|
|
190 |
create table t1 (a char(2) character set binary);
|
|
191 |
insert into t1 values ('aa'), ('bb');
|
|
192 |
select * from t1 where a in (NULL, 'aa');
|
|
193 |
a
|
|
194 |
aa
|
|
195 |
drop table t1;
|
|
196 |
create table t1 (id int, key(id));
|
|
197 |
insert into t1 values (1),(2),(3);
|
|
198 |
select count(*) from t1 where id not in (1);
|
|
199 |
count(*)
|
|
200 |
2
|
|
201 |
select count(*) from t1 where id not in (1,2);
|
|
202 |
count(*)
|
|
203 |
1
|
|
204 |
drop table t1;
|
|
205 |
DROP TABLE IF EXISTS t1;
|
|
206 |
CREATE TABLE t1 SELECT 1 IN (2, NULL);
|
|
207 |
SELECT should return NULL.
|
|
208 |
SELECT * FROM t1;
|
|
209 |
1 IN (2, NULL)
|
|
210 |
NULL
|
|
211 |
DROP TABLE t1;
|
|
212 |
End of 4.1 tests
|
|
213 |
CREATE TABLE t1 (a int PRIMARY KEY);
|
|
214 |
INSERT INTO t1 VALUES (44), (45), (46);
|
|
215 |
SELECT * FROM t1 WHERE a IN (45);
|
|
216 |
a
|
|
217 |
45
|
|
218 |
SELECT * FROM t1 WHERE a NOT IN (0, 45);
|
|
219 |
a
|
|
220 |
44
|
|
221 |
46
|
|
222 |
SELECT * FROM t1 WHERE a NOT IN (45);
|
|
223 |
a
|
|
224 |
44
|
|
225 |
46
|
|
226 |
DROP TABLE t1;
|
|
227 |
create table t1 (a int);
|
|
228 |
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
|
229 |
create table t2 (a int, filler char(200), key(a));
|
|
230 |
insert into t2 select C.a*2, 'no' from t1 A, t1 B, t1 C;
|
|
231 |
insert into t2 select C.a*2+1, 'yes' from t1 C;
|
|
232 |
explain
|
|
233 |
select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18);
|
|
234 |
id select_type table type possible_keys key key_len ref rows Extra
|
|
235 |
1 SIMPLE t2 range a a 5 NULL 12 Using index condition; Using MRR
|
|
236 |
select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18);
|
|
237 |
a filler
|
|
238 |
1 yes
|
|
239 |
3 yes
|
|
240 |
5 yes
|
|
241 |
7 yes
|
|
242 |
9 yes
|
|
243 |
11 yes
|
|
244 |
13 yes
|
|
245 |
15 yes
|
|
246 |
17 yes
|
|
247 |
19 yes
|
|
248 |
explain select * from t2 force index(a) where a NOT IN (2,2,2,2,2,2);
|
|
249 |
id select_type table type possible_keys key key_len ref rows Extra
|
|
250 |
1 SIMPLE t2 range a a 5 NULL 912 Using index condition; Using MRR
|
|
251 |
explain select * from t2 force index(a) where a <> 2;
|
|
252 |
id select_type table type possible_keys key key_len ref rows Extra
|
|
253 |
1 SIMPLE t2 range a a 5 NULL 912 Using index condition; Using MRR
|
|
254 |
drop table t2;
|
|
255 |
create table t2 (a datetime, filler char(200), key(a));
|
|
256 |
insert into t2 select '2006-04-25 10:00:00' + interval C.a minute,
|
|
257 |
'no' from t1 A, t1 B, t1 C where C.a % 2 = 0;
|
|
258 |
insert into t2 select '2006-04-25 10:00:00' + interval C.a*2+1 minute,
|
|
259 |
'yes' from t1 C;
|
|
260 |
explain
|
|
261 |
select * from t2 where a NOT IN (
|
|
262 |
'2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00',
|
|
263 |
'2006-04-25 10:06:00', '2006-04-25 10:08:00');
|
|
264 |
id select_type table type possible_keys key key_len ref rows Extra
|
|
265 |
1 SIMPLE t2 range a a 9 NULL 18 Using index condition; Using MRR
|
|
266 |
select * from t2 where a NOT IN (
|
|
267 |
'2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00',
|
|
268 |
'2006-04-25 10:06:00', '2006-04-25 10:08:00');
|
|
269 |
a filler
|
|
270 |
2006-04-25 10:01:00 yes
|
|
271 |
2006-04-25 10:03:00 yes
|
|
272 |
2006-04-25 10:05:00 yes
|
|
273 |
2006-04-25 10:07:00 yes
|
|
274 |
2006-04-25 10:09:00 yes
|
|
275 |
2006-04-25 10:11:00 yes
|
|
276 |
2006-04-25 10:13:00 yes
|
|
277 |
2006-04-25 10:15:00 yes
|
|
278 |
2006-04-25 10:17:00 yes
|
|
279 |
2006-04-25 10:19:00 yes
|
|
280 |
drop table t2;
|
|
281 |
create table t2 (a varchar(10), filler char(200), key(a));
|
|
282 |
insert into t2 select 'foo', 'no' from t1 A, t1 B;
|
|
283 |
insert into t2 select 'barbar', 'no' from t1 A, t1 B;
|
|
284 |
insert into t2 select 'bazbazbaz', 'no' from t1 A, t1 B;
|
|
285 |
insert into t2 values ('fon', '1'), ('fop','1'), ('barbaq','1'),
|
|
286 |
('barbas','1'), ('bazbazbay', '1'),('zz','1');
|
|
287 |
explain select * from t2 where a not in('foo','barbar', 'bazbazbaz');
|
|
288 |
id select_type table type possible_keys key key_len ref rows Extra
|
|
289 |
1 SIMPLE t2 range a a 13 NULL 7 Using index condition; Using MRR
|
|
290 |
drop table t2;
|
|
291 |
create table t2 (a decimal(10,5), filler char(200), key(a));
|
|
292 |
insert into t2 select 345.67890, 'no' from t1 A, t1 B;
|
|
293 |
insert into t2 select 43245.34, 'no' from t1 A, t1 B;
|
|
294 |
insert into t2 select 64224.56344, 'no' from t1 A, t1 B;
|
|
295 |
insert into t2 values (0, '1'), (22334.123,'1'), (33333,'1'),
|
|
296 |
(55555,'1'), (77777, '1');
|
|
297 |
explain
|
|
298 |
select * from t2 where a not in (345.67890, 43245.34, 64224.56344);
|
|
299 |
id select_type table type possible_keys key key_len ref rows Extra
|
|
300 |
1 SIMPLE t2 range a a 7 NULL 7 Using index condition; Using MRR
|
|
301 |
select * from t2 where a not in (345.67890, 43245.34, 64224.56344);
|
|
302 |
a filler
|
|
303 |
0.00000 1
|
|
304 |
22334.12300 1
|
|
305 |
33333.00000 1
|
|
306 |
55555.00000 1
|
|
307 |
77777.00000 1
|
|
308 |
drop table t2;
|
|
309 |
create table t2 (a int, key(a), b int);
|
|
310 |
insert into t2 values (1,1),(2,2);
|
|
311 |
set @cnt= 1;
|
|
312 |
set @str="update t2 set b=1 where a not in (";
|
|
313 |
select count(*) from (
|
|
314 |
select @str:=concat(@str, @cnt:=@cnt+1, ",")
|
|
315 |
from t1 A, t1 B, t1 C, t1 D) Z;
|
|
316 |
count(*)
|
|
317 |
10000
|
|
318 |
set @str:=concat(@str, "10000)");
|
|
319 |
select substr(@str, 1, 50);
|
|
320 |
substr(@str, 1, 50)
|
|
321 |
update t2 set b=1 where a not in (2,3,4,5,6,7,8,9,
|
|
322 |
set @str=NULL;
|
|
323 |
drop table t2;
|
|
324 |
drop table t1;
|
|
325 |
create table t1 (
|
|
326 |
some_id smallint(5) unsigned,
|
|
327 |
key (some_id)
|
|
328 |
);
|
|
329 |
insert into t1 values (1),(2);
|
|
330 |
select some_id from t1 where some_id not in(2,-1);
|
|
331 |
some_id
|
|
332 |
1
|
|
333 |
select some_id from t1 where some_id not in(-4,-1,-4);
|
|
334 |
some_id
|
|
335 |
1
|
|
336 |
2
|
|
337 |
select some_id from t1 where some_id not in(-4,-1,3423534,2342342);
|
|
338 |
some_id
|
|
339 |
1
|
|
340 |
2
|
|
341 |
select some_id from t1 where some_id not in('-1', '0');
|
|
342 |
some_id
|
|
343 |
1
|
|
344 |
2
|
|
345 |
drop table t1;
|
|
346 |
CREATE TABLE t1 (a int, b int, PRIMARY KEY (a));
|
|
347 |
INSERT INTO t1 VALUES (1,1),(2,1),(3,1),(4,1),(5,1),(6,1);
|
|
348 |
CREATE TABLE t2 (a int, b int, PRIMARY KEY (a));
|
|
349 |
INSERT INTO t2 VALUES (3,2),(4,2),(100,100),(101,201),(102,102);
|
|
350 |
CREATE TABLE t3 (a int PRIMARY KEY);
|
|
351 |
INSERT INTO t3 VALUES (1),(2),(3),(4);
|
|
352 |
CREATE TABLE t4 (a int PRIMARY KEY,b int);
|
|
353 |
INSERT INTO t4 VALUES (1,1),(2,2),(1000,1000),(1001,1001),(1002,1002),
|
|
354 |
(1003,1003),(1004,1004);
|
|
355 |
EXPLAIN SELECT STRAIGHT_JOIN * FROM t3
|
|
356 |
JOIN t1 ON t3.a=t1.a
|
|
357 |
JOIN t2 ON t3.a=t2.a
|
|
358 |
JOIN t4 WHERE t4.a IN (t1.b, t2.b);
|
|
359 |
id select_type table type possible_keys key key_len ref rows Extra
|
|
360 |
1 SIMPLE t3 index PRIMARY PRIMARY 4 NULL 4 Using index
|
|
361 |
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t3.a 1
|
|
362 |
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t3.a 1
|
|
363 |
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 7 Range checked for each record (index map: 0x1)
|
|
364 |
SELECT STRAIGHT_JOIN * FROM t3
|
|
365 |
JOIN t1 ON t3.a=t1.a
|
|
366 |
JOIN t2 ON t3.a=t2.a
|
|
367 |
JOIN t4 WHERE t4.a IN (t1.b, t2.b);
|
|
368 |
a a b a b a b
|
|
369 |
3 3 1 3 2 1 1
|
|
370 |
3 3 1 3 2 2 2
|
|
371 |
4 4 1 4 2 1 1
|
|
372 |
4 4 1 4 2 2 2
|
|
373 |
EXPLAIN SELECT STRAIGHT_JOIN
|
|
374 |
(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b))
|
|
375 |
FROM t3, t1, t2
|
|
376 |
WHERE t3.a=t1.a AND t3.a=t2.a;
|
|
377 |
id select_type table type possible_keys key key_len ref rows Extra
|
|
378 |
1 PRIMARY t3 index PRIMARY PRIMARY 4 NULL 4 Using index
|
|
379 |
1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t3.a 1
|
|
380 |
1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t3.a 1
|
|
381 |
2 DEPENDENT SUBQUERY t4 index NULL PRIMARY 4 NULL 7 Using where; Using index
|
|
382 |
SELECT STRAIGHT_JOIN
|
|
383 |
(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b))
|
|
384 |
FROM t3, t1, t2
|
|
385 |
WHERE t3.a=t1.a AND t3.a=t2.a;
|
|
386 |
(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b))
|
|
387 |
3
|
|
388 |
3
|
|
389 |
DROP TABLE t1,t2,t3,t4;
|
|
390 |
CREATE TABLE t1(a BIGINT UNSIGNED);
|
|
391 |
INSERT INTO t1 VALUES (0xFFFFFFFFFFFFFFFF);
|
|
392 |
SELECT * FROM t1 WHERE a=-1 OR a=-2 ;
|
|
393 |
a
|
|
394 |
SELECT * FROM t1 WHERE a IN (-1, -2);
|
|
395 |
a
|
|
396 |
CREATE TABLE t2 (a BIGINT UNSIGNED);
|
|
397 |
insert into t2 values(13491727406643098568),
|
|
398 |
(0x7fffffefffffffff),
|
|
399 |
(0x7ffffffeffffffff),
|
|
400 |
(0x7fffffffefffffff),
|
|
401 |
(0x7ffffffffeffffff),
|
|
402 |
(0x7fffffffffefffff),
|
|
403 |
(0x7ffffffffffeffff),
|
|
404 |
(0x7fffffffffffefff),
|
|
405 |
(0x7ffffffffffffeff),
|
|
406 |
(0x7fffffffffffffef),
|
|
407 |
(0x7ffffffffffffffe),
|
|
408 |
(0x7fffffffffffffff),
|
|
409 |
(0x8000000000000000),
|
|
410 |
(0x8000000000000001),
|
|
411 |
(0x8000000000000002),
|
|
412 |
(0x8000000000000300),
|
|
413 |
(0x8000000000000400),
|
|
414 |
(0x8000000000000401),
|
|
415 |
(0x8000000000004001),
|
|
416 |
(0x8000000000040001),
|
|
417 |
(0x8000000000400001),
|
|
418 |
(0x8000000004000001),
|
|
419 |
(0x8000000040000001),
|
|
420 |
(0x8000000400000001),
|
|
421 |
(0x8000004000000001),
|
|
422 |
(0x8000040000000001);
|
|
423 |
SELECT HEX(a) FROM t2 WHERE a IN
|
|
424 |
(CAST(0xBB3C3E98175D33C8 AS UNSIGNED),
|
|
425 |
42);
|
|
426 |
HEX(a)
|
|
427 |
BB3C3E98175D33C8
|
|
428 |
SELECT HEX(a) FROM t2 WHERE a IN
|
|
429 |
(CAST(0xBB3C3E98175D33C8 AS UNSIGNED),
|
|
430 |
CAST(0x7fffffffffffffff AS UNSIGNED),
|
|
431 |
CAST(0x8000000000000000 AS UNSIGNED),
|
|
432 |
CAST(0x8000000000000400 AS UNSIGNED),
|
|
433 |
CAST(0x8000000000000401 AS UNSIGNED),
|
|
434 |
42);
|
|
435 |
HEX(a)
|
|
436 |
BB3C3E98175D33C8
|
|
437 |
7FFFFFFFFFFFFFFF
|
|
438 |
8000000000000000
|
|
439 |
8000000000000400
|
|
440 |
8000000000000401
|
|
441 |
SELECT HEX(a) FROM t2 WHERE a IN
|
|
442 |
(CAST(0x7fffffffffffffff AS UNSIGNED),
|
|
443 |
CAST(0x8000000000000001 AS UNSIGNED));
|
|
444 |
HEX(a)
|
|
445 |
7FFFFFFFFFFFFFFF
|
|
446 |
8000000000000001
|
|
447 |
SELECT HEX(a) FROM t2 WHERE a IN
|
|
448 |
(CAST(0x7ffffffffffffffe AS UNSIGNED),
|
|
449 |
CAST(0x7fffffffffffffff AS UNSIGNED));
|
|
450 |
HEX(a)
|
|
451 |
7FFFFFFFFFFFFFFE
|
|
452 |
7FFFFFFFFFFFFFFF
|
|
453 |
SELECT HEX(a) FROM t2 WHERE a IN
|
|
454 |
(0x7ffffffffffffffe,
|
|
455 |
0x7fffffffffffffff,
|
|
456 |
'abc');
|
|
457 |
HEX(a)
|
|
458 |
7FFFFFFFFFFFFFFE
|
|
459 |
7FFFFFFFFFFFFFFF
|
|
460 |
CREATE TABLE t3 (a BIGINT UNSIGNED);
|
|
461 |
INSERT INTO t3 VALUES (9223372036854775551);
|
|
462 |
SELECT HEX(a) FROM t3 WHERE a IN (9223372036854775807, 42);
|
|
463 |
HEX(a)
|
|
464 |
CREATE TABLE t4 (a DATE);
|
|
465 |
INSERT INTO t4 VALUES ('1972-02-06'), ('1972-07-29');
|
|
466 |
SELECT * FROM t4 WHERE a IN ('1972-02-06','19772-07-29');
|
|
467 |
a
|
|
468 |
1972-02-06
|
|
469 |
Warnings:
|
|
470 |
Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1
|
|
471 |
DROP TABLE t1,t2,t3,t4;
|
|
472 |
CREATE TABLE t1 (id int not null);
|
|
473 |
INSERT INTO t1 VALUES (1),(2);
|
|
474 |
SELECT id FROM t1 WHERE id IN(4564, (SELECT IF(1=0,1,1/0)) );
|
|
475 |
id
|
|
476 |
DROP TABLE t1;
|
|
477 |
End of 5.0 tests
|
|
478 |
create table t1(f1 char(1));
|
|
479 |
insert into t1 values ('a'),('b'),('1');
|
|
480 |
select f1 from t1 where f1 in ('a',1);
|
|
481 |
f1
|
|
482 |
a
|
|
483 |
1
|
|
484 |
Warnings:
|
|
485 |
Warning 1292 Truncated incorrect DOUBLE value: 'b'
|
|
486 |
select f1, case f1 when 'a' then '+' when 1 then '-' end from t1;
|
|
487 |
f1 case f1 when 'a' then '+' when 1 then '-' end
|
|
488 |
a +
|
|
489 |
b NULL
|
|
490 |
1 -
|
|
491 |
Warnings:
|
|
492 |
Warning 1292 Truncated incorrect DOUBLE value: 'b'
|
|
493 |
create index t1f1_idx on t1(f1);
|
|
494 |
select f1 from t1 where f1 in ('a',1);
|
|
495 |
f1
|
|
496 |
1
|
|
497 |
a
|
|
498 |
Warnings:
|
|
499 |
Warning 1292 Truncated incorrect DOUBLE value: 'b'
|
|
500 |
explain select f1 from t1 where f1 in ('a',1);
|
|
501 |
id select_type table type possible_keys key key_len ref rows Extra
|
|
502 |
1 SIMPLE t1 index t1f1_idx t1f1_idx 2 NULL 3 Using where; Using index
|
|
503 |
select f1 from t1 where f1 in ('a','b');
|
|
504 |
f1
|
|
505 |
a
|
|
506 |
b
|
|
507 |
explain select f1 from t1 where f1 in ('a','b');
|
|
508 |
id select_type table type possible_keys key key_len ref rows Extra
|
|
509 |
1 SIMPLE t1 index t1f1_idx t1f1_idx 2 NULL 3 Using where; Using index
|
|
510 |
select f1 from t1 where f1 in (2,1);
|
|
511 |
f1
|
|
512 |
1
|
|
513 |
Warnings:
|
|
514 |
Warning 1292 Truncated incorrect DOUBLE value: 'a'
|
|
515 |
Warning 1292 Truncated incorrect DOUBLE value: 'b'
|
|
516 |
explain select f1 from t1 where f1 in (2,1);
|
|
517 |
id select_type table type possible_keys key key_len ref rows Extra
|
|
518 |
1 SIMPLE t1 index t1f1_idx t1f1_idx 2 NULL 3 Using where; Using index
|
|
519 |
create table t2(f2 int, index t2f2(f2));
|
|
520 |
insert into t2 values(0),(1),(2);
|
|
521 |
select f2 from t2 where f2 in ('a',2);
|
|
522 |
f2
|
|
523 |
0
|
|
524 |
2
|
|
525 |
Warnings:
|
|
526 |
Warning 1292 Truncated incorrect DOUBLE value: 'a'
|
|
527 |
Warning 1292 Truncated incorrect DOUBLE value: 'a'
|
|
528 |
Warning 1292 Truncated incorrect DOUBLE value: 'a'
|
|
529 |
explain select f2 from t2 where f2 in ('a',2);
|
|
530 |
id select_type table type possible_keys key key_len ref rows Extra
|
|
531 |
1 SIMPLE t2 index t2f2 t2f2 5 NULL 3 Using where; Using index
|
|
532 |
select f2 from t2 where f2 in ('a','b');
|
|
533 |
f2
|
|
534 |
0
|
|
535 |
Warnings:
|
|
536 |
Warning 1292 Truncated incorrect DOUBLE value: 'a'
|
|
537 |
Warning 1292 Truncated incorrect DOUBLE value: 'b'
|
|
538 |
explain select f2 from t2 where f2 in ('a','b');
|
|
539 |
id select_type table type possible_keys key key_len ref rows Extra
|
|
540 |
1 SIMPLE t2 index t2f2 t2f2 5 NULL 3 Using where; Using index
|
|
541 |
Warnings:
|
|
542 |
Warning 1292 Truncated incorrect DOUBLE value: 'a'
|
|
543 |
Warning 1292 Truncated incorrect DOUBLE value: 'b'
|
|
544 |
select f2 from t2 where f2 in (1,'b');
|
|
545 |
f2
|
|
546 |
0
|
|
547 |
1
|
|
548 |
Warnings:
|
|
549 |
Warning 1292 Truncated incorrect DOUBLE value: 'b'
|
|
550 |
Warning 1292 Truncated incorrect DOUBLE value: 'b'
|
|
551 |
explain select f2 from t2 where f2 in (1,'b');
|
|
552 |
id select_type table type possible_keys key key_len ref rows Extra
|
|
553 |
1 SIMPLE t2 index t2f2 t2f2 5 NULL 3 Using where; Using index
|
|
554 |
drop table t1, t2;
|
|
555 |
create table t1 (a time, key(a));
|
|
556 |
insert into t1 values (),(),(),(),(),(),(),(),(),();
|
|
557 |
select a from t1 where a not in (a,a,a) group by a;
|
|
558 |
a
|
|
559 |
drop table t1;
|
|
560 |
End of 5.1 tests
|