1
drop table if exists t1;
2
select (1,2,3) IN ((3,2,3), (1,2,3), (1,3,3));
3
(1,2,3) IN ((3,2,3), (1,2,3), (1,3,3))
5
select row(10,2,3) IN (row(3,2,3), row(1,2,3), row(1,3,3));
6
row(10,2,3) IN (row(3,2,3), row(1,2,3), row(1,3,3))
8
select row(1,2,3) IN (row(3,NULL,3), row(1,2,3), row(1,3,3));
9
row(1,2,3) IN (row(3,NULL,3), row(1,2,3), row(1,3,3))
11
select row(10,2,3) IN (row(3,NULL,3), row(1,2,3), row(1,3,3));
12
row(10,2,3) IN (row(3,NULL,3), row(1,2,3), row(1,3,3))
14
select row('a',1.5,3) IN (row(1,2,3), row('a',1.5,3), row('a','a','a'));
15
row('a',1.5,3) IN (row(1,2,3), row('a',1.5,3), row('a','a','a'))
18
Warning 1292 Truncated incorrect DECIMAL value: 'a'
19
Warning 1292 Truncated incorrect INTEGER value: 'a'
20
select row('a',0,3) IN (row(3,2,3), row('a','a','3'), row(1,3,3));
21
row('a',0,3) IN (row(3,2,3), row('a','a','3'), row(1,3,3))
24
Warning 1292 Truncated incorrect INTEGER value: 'a'
25
select row('a',0,3) IN (row(3,2,3), row('a','0','3'), row(1,3,3));
26
row('a',0,3) IN (row(3,2,3), row('a','0','3'), row(1,3,3))
28
select row('a',1.5,3) IN (row(3,NULL,3), row('a',1.5,3), row(1,3,3));
29
row('a',1.5,3) IN (row(3,NULL,3), row('a',1.5,3), row(1,3,3))
31
select row('b',1.5,3) IN (row(3,NULL,3), row('a',1.5,3), row(1,3,3));
32
row('b',1.5,3) IN (row(3,NULL,3), row('a',1.5,3), row(1,3,3))
34
select row('b',1.5,3) IN (row('b',NULL,3), row('a',1.5,3), row(1,3,3));
35
row('b',1.5,3) IN (row('b',NULL,3), row('a',1.5,3), row(1,3,3))
37
select row('b',1.5,3) IN (row('b',NULL,4), row('a',1.5,3), row(1,3,3));
38
row('b',1.5,3) IN (row('b',NULL,4), row('a',1.5,3), row(1,3,3))
40
select (1,2,(3,4)) IN ((3,2,(3,4)), (1,2,(3,4)));
41
(1,2,(3,4)) IN ((3,2,(3,4)), (1,2,(3,4)))
43
select row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,4));
44
ERROR 21000: Operand should contain 2 column(s)
45
select row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,row(3,NULL)));
46
row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,row(3,NULL)))
48
explain extended select row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,row(3,NULL)));
49
id select_type table type possible_keys key key_len ref rows filtered Extra
50
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
52
Note 1003 select ((1,2,(3,4)) in ((3,2,(3,4)),(1,2,(3,NULL)))) AS `row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,row(3,NULL)))`
53
SELECT (1,2,3)=(0,NULL,3);
56
SELECT (1,2,3)=(1,NULL,3);
59
SELECT (1,2,3)=(1,NULL,0);
62
SELECT ROW(1,2,3)=ROW(1,2,3);
65
SELECT ROW(2,2,3)=ROW(1+1,2,3);
66
ROW(2,2,3)=ROW(1+1,2,3)
68
SELECT ROW(1,2,3)=ROW(1+1,2,3);
69
ROW(1,2,3)=ROW(1+1,2,3)
71
SELECT ROW(1,2,3)<ROW(1+1,2,3);
72
ROW(1,2,3)<ROW(1+1,2,3)
74
SELECT ROW(1,2,3)>ROW(1+1,2,3);
75
ROW(1,2,3)>ROW(1+1,2,3)
77
SELECT ROW(1,2,3)<=ROW(1+1,2,3);
78
ROW(1,2,3)<=ROW(1+1,2,3)
80
SELECT ROW(1,2,3)>=ROW(1+1,2,3);
81
ROW(1,2,3)>=ROW(1+1,2,3)
83
SELECT ROW(1,2,3)<>ROW(1+1,2,3);
84
ROW(1,2,3)<>ROW(1+1,2,3)
86
SELECT ROW(NULL,2,3)=ROW(NULL,2,3);
87
ROW(NULL,2,3)=ROW(NULL,2,3)
89
SELECT ROW(NULL,2,3)<=>ROW(NULL,2,3);
90
ROW(NULL,2,3)<=>ROW(NULL,2,3)
92
SELECT ROW(1,2,ROW(3,4,5))=ROW(1,2,ROW(3,4,5));
93
ROW(1,2,ROW(3,4,5))=ROW(1,2,ROW(3,4,5))
95
SELECT ROW('test',2,3.33)=ROW('test',2,3.33);
96
ROW('test',2,3.33)=ROW('test',2,3.33)
98
SELECT ROW('test',2,3.33)=ROW('test',2,3.33,4);
99
ERROR 21000: Operand should contain 3 column(s)
100
SELECT ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,33));
101
ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,33))
103
SELECT ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,3));
104
ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,3))
106
SELECT ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,NULL));
107
ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,NULL))
109
SELECT ROW('test',2,ROW(3,33))=ROW('test',2,4);
110
ERROR 21000: Operand should contain 2 column(s)
111
create table t1 ( a int, b int, c int);
112
insert into t1 values (1,2,3), (2,3,1), (3,2,1), (1,2,NULL);
113
select * from t1 where ROW(1,2,3)=ROW(a,b,c);
116
select * from t1 where ROW(0,2,3)=ROW(a,b,c);
118
select * from t1 where ROW(1,2,3)<ROW(a,b,c);
122
select ROW(a,2,3) IN(row(1,b,c), row(2,3,1)) from t1;
123
ROW(a,2,3) IN(row(1,b,c), row(2,3,1))
128
select ROW(c,2,3) IN(row(1,b,a), row(2,3,1)) from t1;
129
ROW(c,2,3) IN(row(1,b,a), row(2,3,1))
134
select ROW(a,b,c) IN(row(1,2,3), row(3,2,1)) from t1;
135
ROW(a,b,c) IN(row(1,2,3), row(3,2,1))
140
select ROW(1,2,3) IN(row(a,b,c), row(1,2,3)) from t1;
141
ROW(1,2,3) IN(row(a,b,c), row(1,2,3))
148
ERROR 21000: Operand should contain 1 column(s)
149
create table t1 (i int);
150
select 1 from t1 where ROW(1,1);
151
ERROR 21000: Operand should contain 1 column(s)
152
select count(*) from t1 order by ROW(1,1);
153
ERROR 21000: Operand should contain 1 column(s)
154
select count(*) from t1 having (1,1) order by i;
155
ERROR 21000: Operand should contain 1 column(s)
157
create table t1 (a int, b int);
158
insert into t1 values (1, 4);
159
insert into t1 values (10, 40);
160
insert into t1 values (1, 4);
161
insert into t1 values (10, 43);
162
insert into t1 values (1, 4);
163
insert into t1 values (10, 41);
164
insert into t1 values (1, 4);
165
insert into t1 values (10, 43);
166
insert into t1 values (1, 4);
167
select a, MAX(b), (1, MAX(b)) = (1, 4) from t1 group by a;
168
a MAX(b) (1, MAX(b)) = (1, 4)
172
SELECT ROW(2,10) <=> ROW(3,4);
173
ROW(2,10) <=> ROW(3,4)
175
SELECT ROW(NULL,10) <=> ROW(3,NULL);
176
ROW(NULL,10) <=> ROW(3,NULL)
178
SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),ROW(1,1));
179
ERROR 21000: Operand should contain 2 column(s)
180
SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),ROW(1,1),ROW(1,ROW(2,3)));
181
ERROR 21000: Operand should contain 2 column(s)
182
SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),ROW(1,ROW(2,2,2)));
183
ERROR 21000: Operand should contain 2 column(s)
184
SELECT ROW(1,ROW(2,3,4)) IN (ROW(1,ROW(2,3,4)),ROW(1,ROW(2,2)));
185
ERROR 21000: Operand should contain 3 column(s)
186
SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),(SELECT 1,1));
187
ERROR 21000: Operand should contain 2 column(s)
188
SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),(SELECT 1,1),ROW(1,ROW(2,4)));
189
ERROR 21000: Operand should contain 2 column(s)
190
SELECT ROW(1,ROW(2,3)) IN ((SELECT 1,1),ROW(1,ROW(2,3)));
191
ERROR 21000: Operand should contain 2 column(s)
192
SELECT ROW(2,1) IN (ROW(21,2),ROW(ROW(1,1,3),0));
193
ERROR 21000: Operand should contain 1 column(s)
194
SELECT ROW(2,1) IN (ROW(ROW(1,1,3),0),ROW(21,2));
195
ERROR 21000: Operand should contain 1 column(s)
196
CREATE TABLE t1(a int, b int, c int);
197
INSERT INTO t1 VALUES (1, 2, 3),
198
(NULL, 2, 3 ), (1, NULL, 3 ), (1, 2, NULL),
199
(NULL, 2, 3+1), (1, NULL, 3+1), (1, 2+1, NULL),
200
(NULL, 2, 3-1), (1, NULL, 3-1), (1, 2-1, NULL);
201
SELECT (1,2,3) = (1, NULL, 3);
202
(1,2,3) = (1, NULL, 3)
204
SELECT (1,2,3) = (1+1, NULL, 3);
205
(1,2,3) = (1+1, NULL, 3)
207
SELECT (1,2,3) = (1, NULL, 3+1);
208
(1,2,3) = (1, NULL, 3+1)
210
SELECT * FROM t1 WHERE (a,b,c) = (1,2,3);
213
SELECT (1,2,3) <> (1, NULL, 3);
214
(1,2,3) <> (1, NULL, 3)
216
SELECT (1,2,3) <> (1+1, NULL, 3);
217
(1,2,3) <> (1+1, NULL, 3)
219
SELECT (1,2,3) <> (1, NULL, 3+1);
220
(1,2,3) <> (1, NULL, 3+1)
222
SELECT * FROM t1 WHERE (a,b,c) <> (1,2,3);
230
SELECT (1,2,3) < (NULL, 2, 3);
231
(1,2,3) < (NULL, 2, 3)
233
SELECT (1,2,3) < (1, NULL, 3);
234
(1,2,3) < (1, NULL, 3)
236
SELECT (1,2,3) < (1-1, NULL, 3);
237
(1,2,3) < (1-1, NULL, 3)
239
SELECT (1,2,3) < (1+1, NULL, 3);
240
(1,2,3) < (1+1, NULL, 3)
242
SELECT * FROM t1 WHERE (a,b,c) < (1,2,3);
245
SELECT (1,2,3) <= (NULL, 2, 3);
246
(1,2,3) <= (NULL, 2, 3)
248
SELECT (1,2,3) <= (1, NULL, 3);
249
(1,2,3) <= (1, NULL, 3)
251
SELECT (1,2,3) <= (1-1, NULL, 3);
252
(1,2,3) <= (1-1, NULL, 3)
254
SELECT (1,2,3) <= (1+1, NULL, 3);
255
(1,2,3) <= (1+1, NULL, 3)
257
SELECT * FROM t1 WHERE (a,b,c) <= (1,2,3);
261
SELECT (1,2,3) > (NULL, 2, 3);
262
(1,2,3) > (NULL, 2, 3)
264
SELECT (1,2,3) > (1, NULL, 3);
265
(1,2,3) > (1, NULL, 3)
267
SELECT (1,2,3) > (1-1, NULL, 3);
268
(1,2,3) > (1-1, NULL, 3)
270
SELECT (1,2,3) > (1+1, NULL, 3);
271
(1,2,3) > (1+1, NULL, 3)
273
SELECT * FROM t1 WHERE (a,b,c) > (1,2,3);
276
SELECT (1,2,3) >= (NULL, 2, 3);
277
(1,2,3) >= (NULL, 2, 3)
279
SELECT (1,2,3) >= (1, NULL, 3);
280
(1,2,3) >= (1, NULL, 3)
282
SELECT (1,2,3) >= (1-1, NULL, 3);
283
(1,2,3) >= (1-1, NULL, 3)
285
SELECT (1,2,3) >= (1+1, NULL, 3);
286
(1,2,3) >= (1+1, NULL, 3)
288
SELECT * FROM t1 WHERE (a,b,c) >= (1,2,3);
293
SELECT ROW(1,1,1) = ROW(1,1,1) as `1`, ROW(1,1,1) = ROW(1,2,1) as `0`, ROW(1,NULL,1) = ROW(2,2,1) as `0`, ROW(1,NULL,1) = ROW(1,2,2) as `0`, ROW(1,NULL,1) = ROW(1,2,1) as `null` ;
296
select row(NULL,1)=(2,0);
299
CREATE TABLE t1 (a int, b int, PRIMARY KEY (a,b));
300
INSERT INTO t1 VALUES (1,1), (2,1), (3,1), (1,2), (3,2), (3,3);
301
EXPLAIN SELECT * FROM t1 WHERE a=3 AND b=2;
302
id select_type table type possible_keys key key_len ref rows Extra
303
1 SIMPLE t1 const PRIMARY PRIMARY 8 const,const 1 Using index
304
EXPLAIN SELECT * FROM t1 WHERE (a,b)=(3,2);
305
id select_type table type possible_keys key key_len ref rows Extra
306
1 SIMPLE t1 const PRIMARY PRIMARY 8 const,const 1 Using index
307
SELECT * FROM t1 WHERE a=3 and b=2;
310
SELECT * FROM t1 WHERE (a,b)=(3,2);
313
CREATE TABLE t2 (a int, b int, c int, PRIMARY KEY (a,b,c));
314
INSERT INTO t2 VALUES
315
(1,1,2), (3,1,3), (1,2,2), (4,4,2),
316
(1,1,1), (3,1,1), (1,2,1);
317
EXPLAIN SELECT * FROM t1,t2 WHERE t1.a=t2.a AND t1.b=t2.b;
318
id select_type table type possible_keys key key_len ref rows Extra
319
1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL 6 Using index
320
1 SIMPLE t2 ref PRIMARY PRIMARY 8 test.t1.a,test.t1.b 1 Using index
321
EXPLAIN SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,t2.b);
322
id select_type table type possible_keys key key_len ref rows Extra
323
1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL 6 Using index
324
1 SIMPLE t2 ref PRIMARY PRIMARY 8 test.t1.a,test.t1.b 1 Using index
325
SELECT * FROM t1,t2 WHERE t1.a=t2.a and t1.b=t2.b;
333
SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,t2.b);
341
EXPLAIN SELECT * FROM t1,t2 WHERE t1.a=t2.a AND t1.b=2;
342
id select_type table type possible_keys key key_len ref rows Extra
343
1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL 6 Using where; Using index
344
1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a 1 Using index
345
EXPLAIN SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,2);
346
id select_type table type possible_keys key key_len ref rows Extra
347
1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL 6 Using where; Using index
348
1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a 1 Using index
349
SELECT * FROM t1,t2 WHERE t1.a=1 and t1.b=t2.b;
357
SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,2);
365
EXPLAIN EXTENDED SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,t2.b+1);
366
id select_type table type possible_keys key key_len ref rows filtered Extra
367
1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL 6 100.00 Using index
368
1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where; Using index
370
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` = (`test`.`t2`.`b` + 1)))
371
SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,t2.b+1);
377
EXPLAIN EXTENDED SELECT * FROM t1,t2 WHERE (t1.a-1,t1.b)=(t2.a-1,t2.b+1);
378
id select_type table type possible_keys key key_len ref rows filtered Extra
379
1 SIMPLE t1 index NULL PRIMARY 8 NULL 6 100.00 Using index
380
1 SIMPLE t2 index NULL PRIMARY 12 NULL 7 100.00 Using where; Using index; Using join buffer
382
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where (((`test`.`t1`.`a` - 1) = (`test`.`t2`.`a` - 1)) and (`test`.`t1`.`b` = (`test`.`t2`.`b` + 1)))
383
SELECT * FROM t1,t2 WHERE (t1.a-1,t1.b)=(t2.a-1,t2.b+1);
389
EXPLAIN SELECT * FROM t2 WHERE a=3 AND b=2;
390
id select_type table type possible_keys key key_len ref rows Extra
391
1 SIMPLE t2 ref PRIMARY PRIMARY 8 const,const 1 Using index
392
EXPLAIN SELECT * FROM t2 WHERE (a,b)=(3,2);
393
id select_type table type possible_keys key key_len ref rows Extra
394
1 SIMPLE t2 ref PRIMARY PRIMARY 8 const,const 1 Using index
395
SELECT * FROM t2 WHERE a=3 and b=2;
397
SELECT * FROM t2 WHERE (a,b)=(3,2);
399
EXPLAIN SELECT * FROM t1,t2 WHERE t2.a=t1.a AND t2.b=2 AND t2.c=1;
400
id select_type table type possible_keys key key_len ref rows Extra
401
1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL 6 Using index
402
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 12 test.t1.a,const,const 1 Using index
403
EXPLAIN EXTENDED SELECT * FROM t1,t2 WHERE (t2.a,(t2.b,t2.c))=(t1.a,(2,1));
404
id select_type table type possible_keys key key_len ref rows filtered Extra
405
1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL 6 100.00 Using index
406
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 12 test.t1.a,const,const 1 100.00 Using index
408
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = 1) and (`test`.`t2`.`b` = 2) and (`test`.`t2`.`a` = `test`.`t1`.`a`))
409
SELECT * FROM t1,t2 WHERE (t2.a,(t2.b,t2.c))=(t1.a,(2,1));
413
EXPLAIN EXTENDED SELECT * FROM t1,t2 WHERE t2.a=t1.a AND (t2.b,t2.c)=(2,1);
414
id select_type table type possible_keys key key_len ref rows filtered Extra
415
1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL 6 100.00 Using index
416
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 12 test.t1.a,const,const 1 100.00 Using index
418
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = 1) and (`test`.`t2`.`b` = 2) and (`test`.`t2`.`a` = `test`.`t1`.`a`))
419
SELECT * FROM t1,t2 WHERE t2.a=t1.a AND (t2.b,t2.c)=(2,1);
425
a int, b int, c int, d int, e int, f int, g int, h int,
426
PRIMARY KEY (a,b,c,d,e,f,g)
428
INSERT INTO t1 VALUES (1,2,3,4,5,6,7,99);
429
SELECT h FROM t1 WHERE (a,b,c,d,e,f,g)=(1,2,3,4,5,6,7);
432
SET @x:= (SELECT h FROM t1 WHERE (a,b,c,d,e,f,g)=(1,2,3,4,5,6,7));
437
CREATE TABLE t1 (a INT, b INT);
438
INSERT INTO t1 VALUES (1,1);
439
SELECT ROW(a, 1) IN (SELECT SUM(b), 1) FROM t1 GROUP BY a;
440
ROW(a, 1) IN (SELECT SUM(b), 1)
442
SELECT ROW(a, 1) IN (SELECT SUM(b), 3) FROM t1 GROUP BY a;
443
ROW(a, 1) IN (SELECT SUM(b), 3)