2003-01-06 00:48:59 +01:00
|
|
|
|
# Initialise
|
|
|
|
|
--disable_warnings
|
|
|
|
|
drop table if exists t1;
|
|
|
|
|
--enable_warnings
|
2000-12-28 02:56:38 +01:00
|
|
|
|
#
|
|
|
|
|
# test of IN (NULL)
|
|
|
|
|
#
|
|
|
|
|
|
2002-12-06 20:55:53 +01:00
|
|
|
|
select 1 in (1,2,3);
|
|
|
|
|
select 10 in (1,2,3);
|
|
|
|
|
select NULL in (1,2,3);
|
|
|
|
|
select 1 in (1,NULL,3);
|
|
|
|
|
select 3 in (1,NULL,3);
|
|
|
|
|
select 10 in (1,NULL,3);
|
|
|
|
|
select 1.5 in (1.5,2.5,3.5);
|
|
|
|
|
select 10.5 in (1.5,2.5,3.5);
|
|
|
|
|
select NULL in (1.5,2.5,3.5);
|
|
|
|
|
select 1.5 in (1.5,NULL,3.5);
|
|
|
|
|
select 3.5 in (1.5,NULL,3.5);
|
|
|
|
|
select 10.5 in (1.5,NULL,3.5);
|
2003-01-06 00:48:59 +01:00
|
|
|
|
|
2002-12-06 20:55:53 +01:00
|
|
|
|
CREATE TABLE t1 (a int, b int, c int);
|
|
|
|
|
insert into t1 values (1,2,3), (1,NULL,3);
|
|
|
|
|
select 1 in (a,b,c) from t1;
|
|
|
|
|
select 3 in (a,b,c) from t1;
|
|
|
|
|
select 10 in (a,b,c) from t1;
|
|
|
|
|
select NULL in (a,b,c) from t1;
|
|
|
|
|
drop table t1;
|
|
|
|
|
CREATE TABLE t1 (a float, b float, c float);
|
|
|
|
|
insert into t1 values (1.5,2.5,3.5), (1.5,NULL,3.5);
|
|
|
|
|
select 1.5 in (a,b,c) from t1;
|
|
|
|
|
select 3.5 in (a,b,c) from t1;
|
|
|
|
|
select 10.5 in (a,b,c) from t1;
|
|
|
|
|
drop table t1;
|
|
|
|
|
CREATE TABLE t1 (a varchar(10), b varchar(10), c varchar(10));
|
|
|
|
|
insert into t1 values ('A','BC','EFD'), ('A',NULL,'EFD');
|
|
|
|
|
select 'A' in (a,b,c) from t1;
|
|
|
|
|
select 'EFD' in (a,b,c) from t1;
|
|
|
|
|
select 'XSFGGHF' in (a,b,c) from t1;
|
|
|
|
|
drop table t1;
|
|
|
|
|
|
2000-12-28 02:56:38 +01:00
|
|
|
|
CREATE TABLE t1 (field char(1));
|
|
|
|
|
INSERT INTO t1 VALUES ('A'),(NULL);
|
|
|
|
|
SELECT * from t1 WHERE field IN (NULL);
|
|
|
|
|
SELECT * from t1 WHERE field NOT IN (NULL);
|
|
|
|
|
SELECT * from t1 where field = field;
|
|
|
|
|
SELECT * from t1 where field <=> field;
|
|
|
|
|
DELETE FROM t1 WHERE field NOT IN (NULL);
|
|
|
|
|
SELECT * FROM t1;
|
|
|
|
|
drop table t1;
|
|
|
|
|
|
|
|
|
|
create table t1 (id int(10) primary key);
|
|
|
|
|
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9);
|
|
|
|
|
select * from t1 where id in (2,5,9);
|
|
|
|
|
drop table t1;
|
|
|
|
|
|
2003-07-16 08:29:16 +02:00
|
|
|
|
create table t1 (
|
|
|
|
|
a char(1) character set latin1 collate latin1_general_ci,
|
|
|
|
|
b char(1) character set latin1 collate latin1_swedish_ci,
|
|
|
|
|
c char(1) character set latin1 collate latin1_danish_ci
|
|
|
|
|
);
|
|
|
|
|
insert into t1 values ('A','B','C');
|
|
|
|
|
insert into t1 values ('a','c','c');
|
2004-02-16 09:03:25 +01:00
|
|
|
|
--error 1267
|
2003-07-16 08:29:16 +02:00
|
|
|
|
select * from t1 where a in (b);
|
2003-08-18 23:08:08 +02:00
|
|
|
|
--error 1270
|
2004-02-16 09:03:25 +01:00
|
|
|
|
select * from t1 where a in (b,c);
|
|
|
|
|
--error 1271
|
2003-07-16 08:29:16 +02:00
|
|
|
|
select * from t1 where 'a' in (a,b,c);
|
|
|
|
|
select * from t1 where 'a' in (a);
|
|
|
|
|
select * from t1 where a in ('a');
|
|
|
|
|
select * from t1 where 'a' collate latin1_general_ci in (a,b,c);
|
|
|
|
|
select * from t1 where 'a' collate latin1_bin in (a,b,c);
|
|
|
|
|
select * from t1 where 'a' in (a,b,c collate latin1_bin);
|
2003-10-30 11:57:26 +01:00
|
|
|
|
explain extended select * from t1 where 'a' in (a,b,c collate latin1_bin);
|
2003-07-16 08:29:16 +02:00
|
|
|
|
drop table t1;
|
2003-07-18 11:03:54 +02:00
|
|
|
|
|
2004-09-01 12:39:15 +02:00
|
|
|
|
set names utf8;
|
|
|
|
|
create table t1 (a char(10) character set utf8 not null);
|
|
|
|
|
insert into t1 values ('bbbb'),(_koi8r'<27><><EFBFBD><EFBFBD>'),(_latin1'<27><><EFBFBD><EFBFBD>');
|
|
|
|
|
select a from t1 where a in ('bbbb',_koi8r'<27><><EFBFBD><EFBFBD>',_latin1'<27><><EFBFBD><EFBFBD>') order by a;
|
|
|
|
|
drop table t1;
|
2005-01-20 12:38:56 +01:00
|
|
|
|
# Bug#7834 Illegal mix of collations in IN operator
|
|
|
|
|
create table t1 (a char(10) character set latin1 not null);
|
|
|
|
|
insert into t1 values ('a'),('b'),('c');
|
|
|
|
|
select a from t1 where a IN ('a','b','c') order by a;
|
|
|
|
|
drop table t1;
|
2004-09-01 12:39:15 +02:00
|
|
|
|
set names latin1;
|
|
|
|
|
|
2003-07-18 11:03:54 +02:00
|
|
|
|
select '1.0' in (1,2);
|
|
|
|
|
select 1 in ('1.0',2);
|
|
|
|
|
select 1 in (1,'2.0');
|
|
|
|
|
select 1 in ('1.0',2.0);
|
|
|
|
|
select 1 in (1.0,'2.0');
|
|
|
|
|
select 1 in ('1.1',2);
|
|
|
|
|
select 1 in ('1.1',2.0);
|
2004-11-05 05:39:52 +01:00
|
|
|
|
|
|
|
|
|
# Test case for bug #6365
|
|
|
|
|
|
|
|
|
|
create table t1 (a char(20) character set binary);
|
|
|
|
|
insert into t1 values ('aa'), ('bb');
|
|
|
|
|
select * from t1 where a in (NULL, 'aa');
|
|
|
|
|
drop table t1;
|
2005-07-28 02:22:47 +02:00
|
|
|
|
|
2005-09-23 11:43:20 +02:00
|
|
|
|
# BUG#13419
|
|
|
|
|
create table t1 (id int, key(id));
|
|
|
|
|
insert into t1 values (1),(2),(3);
|
|
|
|
|
select count(*) from t1 where id not in (1);
|
|
|
|
|
select count(*) from t1 where id not in (1,2);
|
|
|
|
|
drop table t1;
|
|
|
|
|
|
2005-07-28 02:22:47 +02:00
|
|
|
|
# End of 4.1 tests
|