📄 func_in.result
字号:
drop table if exists t1;select 1 in (1,2,3);1 in (1,2,3)1select 10 in (1,2,3);10 in (1,2,3)0select NULL in (1,2,3);NULL in (1,2,3)NULLselect 1 in (1,NULL,3);1 in (1,NULL,3)1select 3 in (1,NULL,3);3 in (1,NULL,3)1select 10 in (1,NULL,3);10 in (1,NULL,3)NULLselect 1.5 in (1.5,2.5,3.5);1.5 in (1.5,2.5,3.5)1select 10.5 in (1.5,2.5,3.5);10.5 in (1.5,2.5,3.5)0select NULL in (1.5,2.5,3.5);NULL in (1.5,2.5,3.5)NULLselect 1.5 in (1.5,NULL,3.5);1.5 in (1.5,NULL,3.5)1select 3.5 in (1.5,NULL,3.5);3.5 in (1.5,NULL,3.5)1select 10.5 in (1.5,NULL,3.5);10.5 in (1.5,NULL,3.5)NULLCREATE 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;1 in (a,b,c)11select 3 in (a,b,c) from t1;3 in (a,b,c)11select 10 in (a,b,c) from t1;10 in (a,b,c)0NULLselect NULL in (a,b,c) from t1;NULL in (a,b,c)NULLNULLdrop 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;1.5 in (a,b,c)11select 3.5 in (a,b,c) from t1;3.5 in (a,b,c)11select 10.5 in (a,b,c) from t1;10.5 in (a,b,c)0NULLdrop 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;'A' in (a,b,c)11select 'EFD' in (a,b,c) from t1;'EFD' in (a,b,c)11select 'XSFGGHF' in (a,b,c) from t1;'XSFGGHF' in (a,b,c)0NULLdrop table t1;CREATE TABLE t1 (field char(1));INSERT INTO t1 VALUES ('A'),(NULL);SELECT * from t1 WHERE field IN (NULL);fieldSELECT * from t1 WHERE field NOT IN (NULL);fieldSELECT * from t1 where field = field;fieldASELECT * from t1 where field <=> field;fieldANULLDELETE FROM t1 WHERE field NOT IN (NULL);SELECT * FROM t1;fieldANULLdrop 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);id259drop table t1;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');select * from t1 where a in (b);ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '='select * from t1 where a in (b,c);ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT), (latin1_swedish_ci,IMPLICIT), (latin1_danish_ci,IMPLICIT) for operation ' IN 'select * from t1 where 'a' in (a,b,c);ERROR HY000: Illegal mix of collations for operation ' IN 'select * from t1 where 'a' in (a);a b cA B Ca c cselect * from t1 where a in ('a');a b cA B Ca c cselect * from t1 where 'a' collate latin1_general_ci in (a,b,c);a b cA B Ca c cselect * from t1 where 'a' collate latin1_bin in (a,b,c);a b ca c cselect * from t1 where 'a' in (a,b,c collate latin1_bin);a b ca c cexplain extended select * from t1 where 'a' in (a,b,c collate latin1_bin);id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using whereWarnings:Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (_latin1'a' in (`test`.`t1`.`a`,`test`.`t1`.`b`,(`test`.`t1`.`c` collate latin1_bin)))drop table t1;set names utf8;create table t1 (a char(10) character set utf8 not null);insert into t1 values ('bbbb'),(_koi8r'妹妹'),(_latin1'哪哪');select a from t1 where a in ('bbbb',_koi8r'妹妹',_latin1'哪哪') order by a;a脛脛脛脛bbbb褑褑褑褑drop table t1;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;aabcdrop table t1;set names latin1;select '1.0' in (1,2);'1.0' in (1,2)1select 1 in ('1.0',2);1 in ('1.0',2)1select 1 in (1,'2.0');1 in (1,'2.0')1select 1 in ('1.0',2.0);1 in ('1.0',2.0)1select 1 in (1.0,'2.0');1 in (1.0,'2.0')1select 1 in ('1.1',2);1 in ('1.1',2)0select 1 in ('1.1',2.0);1 in ('1.1',2.0)0create table t1 (a char(2) character set binary);insert into t1 values ('aa'), ('bb');select * from t1 where a in (NULL, 'aa');aaadrop table t1;create table t1 (id int, key(id));insert into t1 values (1),(2),(3);select count(*) from t1 where id not in (1);count(*)2select count(*) from t1 where id not in (1,2);count(*)1drop table t1;CREATE TABLE t1 (a int PRIMARY KEY);INSERT INTO t1 VALUES (44), (45), (46);SELECT * FROM t1 WHERE a IN (45);a45SELECT * FROM t1 WHERE a NOT IN (0, 45);a4446SELECT * FROM t1 WHERE a NOT IN (45);a4446CREATE VIEW v1 AS SELECT * FROM t1 WHERE a NOT IN (45);SHOW CREATE VIEW v1;View Create Viewv1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where (`t1`.`a` <> 45)SELECT * FROM v1;a4446DROP VIEW v1;DROP TABLE t1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -