subselect3.result

来自「视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.」· RESULT 代码 · 共 763 行 · 第 1/2 页

RESULT
763
字号
oref	abb	2dd	NULLselect oref, a, a in (select min(ie) from t1 where oref=t2.oref group bygrp having min(ie) > 1) Z from t2;oref	a	Zee	NULL	0bb	2	0ff	2	1cc	3	0aa	1	0dd	NULL	0bb	NULL	NULLselect oref, a from t2 where a in (select min(ie) from t1 whereoref=t2.oref group by grp having min(ie) > 1);oref	aff	2select oref, a from t2 where a not in (select min(ie) from t1 whereoref=t2.oref group by grp having min(ie) > 1);oref	aee	NULLbb	2cc	3aa	1dd	NULLalter table t1 add index idx(ie);explain select oref, a, a in (select ie from t1 where oref=t2.oref) Z from t2;id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	7	2	DEPENDENT SUBQUERY	t1	index_subquery	idx	idx	5	func	4	Using where; Full scan on NULL keyselect oref, a, a in (select ie from t1 where oref=t2.oref) Z from t2;oref	a	Zee	NULL	NULLbb	2	0ff	2	1cc	3	NULLaa	1	1dd	NULL	0bb	NULL	NULLselect oref, a from t2 where a in (select ie from t1 where oref=t2.oref);oref	aff	2aa	1select oref, a from t2 where a not in (select ie from t1 where oref=t2.oref);oref	abb	2dd	NULLalter table t1 drop index idx;alter table t1 add index idx(oref,ie);explain select oref, a, a in (select ie from t1 where oref=t2.oref) Z from t2;id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	7	2	DEPENDENT SUBQUERY	t1	ref_or_null	idx	idx	10	test.t2.oref,func	4	Using where; Using index; Full scan on NULL keyselect oref, a, a in (select ie from t1 where oref=t2.oref) Z from t2;oref	a	Zee	NULL	NULLbb	2	0ff	2	1cc	3	NULLaa	1	1dd	NULL	0bb	NULL	NULLselect oref, a from t2 where a in (select ie from t1 where oref=t2.oref);oref	aff	2aa	1select oref, a from t2 where a not in (select ie from t1 where oref=t2.oref);oref	abb	2dd	NULLexplain select oref, a, a in (select min(ie) from t1 where oref=t2.oref group by grp having min(ie) > 1) Z from t2;id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	7	2	DEPENDENT SUBQUERY	t1	ref	idx	idx	5	test.t2.oref	2	Using where; Using temporary; Using filesortselect oref, a, a in (select min(ie) from t1 where oref=t2.oref group by grp having min(ie) > 1) Z from t2;oref	a	Zee	NULL	0bb	2	0ff	2	1cc	3	0aa	1	0dd	NULL	0bb	NULL	NULLselect oref, a from t2 where a in (select min(ie) from t1 where oref=t2.oref group by grp having min(ie) > 1);oref	aff	2select oref, a from t2 where a not in (select min(ie) from t1 where oref=t2.oref group by grp having min(ie) > 1);oref	aee	NULLbb	2cc	3aa	1dd	NULLdrop table t1,t2;create table t1 (oref char(4), grp int, ie1 int, ie2 int);insert into t1 (oref, grp, ie1, ie2) values('aa', 10, 2, 1),('aa', 10, 1, 1),('aa', 20, 2, 1),('bb', 10, 3, 1),('cc', 10, 4, 2),('cc', 20, 3, 2),('ee', 10, 2, 1),('ee', 10, 1, 2),('ff', 20, 2, 2),('ff', 20, 1, 2);create table t2 (oref char(4), a int, b int);insert into t2 values ('ee', NULL, 1),('bb', 2, 1),('ff', 2, 2),('cc', 3, NULL),('bb', NULL, NULL),('aa', 1, 1),('dd', 1, NULL);select oref, a, b, (a,b) in (select ie1,ie2 from t1 where oref=t2.oref) Z from t2;oref	a	b	Zee	NULL	1	NULLbb	2	1	0ff	2	2	1cc	3	NULL	NULLbb	NULL	NULL	NULLaa	1	1	1dd	1	NULL	0select oref, a, b from t2 where (a,b) in (select ie1,ie2 from t1 where oref=t2.oref);oref	a	bff	2	2aa	1	1select oref, a, b from t2 where (a,b) not in (select ie1,ie2 from t1 where oref=t2.oref);oref	a	bbb	2	1dd	1	NULLselect oref, a, b, (a,b) in (select min(ie1),max(ie2) from t1 where oref=t2.oref group by grp) Z from t2;oref	a	b	Zee	NULL	1	0bb	2	1	0ff	2	2	0cc	3	NULL	NULLbb	NULL	NULL	NULLaa	1	1	1dd	1	NULL	0select oref, a, b from t2 where (a,b) in (select min(ie1), max(ie2) from t1 where oref=t2.oref group by grp);oref	a	baa	1	1select oref, a, b from t2 where(a,b) not in (select min(ie1), max(ie2) from t1 where oref=t2.oref group by grp);oref	a	bee	NULL	1bb	2	1ff	2	2dd	1	NULLalter table t1 add index idx(ie1,ie2);explain select oref, a, b, (a,b) in (select ie1,ie2 from t1 where oref=t2.oref) Z from t2;id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	7	2	DEPENDENT SUBQUERY	t1	index_subquery	idx	idx	5	func	4	Using where; Full scan on NULL keyselect oref, a, b, (a,b) in (select ie1,ie2 from t1 where oref=t2.oref) Z from t2;oref	a	b	Zee	NULL	1	NULLbb	2	1	0ff	2	2	1cc	3	NULL	NULLbb	NULL	NULL	NULLaa	1	1	1dd	1	NULL	0select oref, a, b from t2 where (a,b) in (select ie1,ie2 from t1 where oref=t2.oref);oref	a	bff	2	2aa	1	1select oref, a, b from t2 where (a,b) not in (select ie1,ie2 from t1 where oref=t2.oref);oref	a	bbb	2	1dd	1	NULLexplain extended select oref, a, b, (a,b) in (select ie1,ie2 from t1 where oref=t2.oref) Z from t2;id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	7	2	DEPENDENT SUBQUERY	t1	index_subquery	idx	idx	5	func	4	Using where; Full scan on NULL keyWarnings:Note	1276	Field or reference 'test.t2.oref' of SELECT #2 was resolved in SELECT #1Note	1003	select `test`.`t2`.`oref` AS `oref`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,<in_optimizer>((`test`.`t2`.`a`,`test`.`t2`.`b`),<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on idx checking NULL where ((`test`.`t1`.`oref` = `test`.`t2`.`oref`) and trigcond(((<cache>(`test`.`t2`.`a`) = `test`.`t1`.`ie1`) or isnull(`test`.`t1`.`ie1`))) and trigcond(((<cache>(`test`.`t2`.`b`) = `test`.`t1`.`ie2`) or isnull(`test`.`t1`.`ie2`)))) having (trigcond(<is_not_null_test>(`test`.`t1`.`ie1`)) and trigcond(<is_not_null_test>(`test`.`t1`.`ie2`)))))) AS `Z` from `test`.`t2`drop table t1,t2;create table t1 (oref char(4), grp int, ie int primary key);insert into t1 (oref, grp, ie) values('aa', 10, 2),('aa', 10, 1),('bb', 10, 3),('cc', 10, 4),('cc', 20, 5),('cc', 10, 6);create table t2 (oref char(4), a int);insert into t2 values ('ee', NULL),('bb', 2),('cc', 5),('cc', 2),('cc', NULL),('aa', 1),('bb', NULL);explain select oref, a, a in (select ie from t1 where oref=t2.oref) Z from t2;id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	7	2	DEPENDENT SUBQUERY	t1	unique_subquery	PRIMARY	PRIMARY	4	func	1	Using where; Full scan on NULL keyselect oref, a, a in (select ie from t1 where oref=t2.oref) Z from t2;oref	a	Zee	NULL	0bb	2	0cc	5	1cc	2	0cc	NULL	NULLaa	1	1bb	NULL	NULLselect oref, a from t2 where a in (select ie from t1 where oref=t2.oref);oref	acc	5aa	1select oref, a from t2 where a not in (select ie from t1 where oref=t2.oref);oref	aee	NULLbb	2cc	2explain select oref, a, a in (select min(ie) from t1 where oref=t2.oref group by grp) Z from t2;id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	7	2	DEPENDENT SUBQUERY	t1	ALL	NULL	NULL	NULL	NULL	6	Using where; Using temporary; Using filesortselect oref, a, a in (select min(ie) from t1 where oref=t2.oref group by grp) Z from t2;oref	a	Zee	NULL	0bb	2	0cc	5	1cc	2	0cc	NULL	NULLaa	1	1bb	NULL	NULLdrop table t1,t2;create table t1 (a int, b int);insert into t1 values (0,0), (2,2), (3,3);create table t2 (a int, b int);insert into t2 values (1,1), (3,3);select a, b, (a,b) in (select a, min(b) from t2 group by a) Z from t1;a	b	Z0	0	02	2	03	3	1insert into t2 values (NULL,4);select a, b, (a,b) in (select a, min(b) from t2 group by a) Z from t1;a	b	Z0	0	02	2	03	3	1drop table t1,t2;CREATE TABLE t1 (a int, b INT, c CHAR(10) NOT NULL, PRIMARY KEY (a, b));INSERT INTO t1 VALUES (1,1,'a'), (1,2,'b'), (1,3,'c'), (1,4,'d'), (1,5,'e'),(2,1,'f'), (2,2,'g'), (2,3,'h'), (3,4,'i'),(3,3,'j'), (3,2,'k'), (3,1,'l'),(1,9,'m');CREATE TABLE t2 (a int, b INT, c CHAR(10) NOT NULL, PRIMARY KEY (a, b));INSERT INTO t2 SELECT * FROM t1;SELECT a, MAX(b), (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b))as test FROM t1 GROUP BY a;a	MAX(b)	test1	9	m2	3	h3	4	iSELECT * FROM t1 GROUP by t1.aHAVING (MAX(t1.b) > (SELECT MAX(t2.b) FROM t2 WHERE t2.c < t1.cHAVING MAX(t2.b+t1.a) < 10));a	b	cSELECT a,b,c FROM t1 WHERE b in (9,3,4) ORDER BY b,c;a	b	c1	3	c2	3	h3	3	j1	4	d3	4	i1	9	mSELECT a, MAX(b),(SELECT COUNT(DISTINCT t.c) FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b) LIMIT 1) as cnt, (SELECT t.b FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b) LIMIT 1) as t_b,(SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b) LIMIT 1) as t_b,(SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b) ORDER BY t.c LIMIT 1)as t_bFROM t1 GROUP BY a;a	MAX(b)	cnt	t_b	t_b	t_b1	9	1	9	m	m2	3	1	3	h	h3	4	1	4	i	iSELECT a, MAX(b),(SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b) LIMIT 1) as test FROM t1 GROUP BY a;a	MAX(b)	test1	9	m2	3	h3	4	iDROP TABLE t1, t2;CREATE TABLE t1 (a int);CREATE TABLE t2 (b int, PRIMARY KEY(b));INSERT INTO t1 VALUES (1), (NULL), (4);INSERT INTO t2 VALUES (3), (1),(2), (5), (4), (7), (6);EXPLAIN EXTENDED SELECT a FROM t1, t2 WHERE a=b AND (b NOT IN (SELECT a FROM t1));id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	3	Using where1	PRIMARY	t2	eq_ref	PRIMARY	PRIMARY	4	test.t1.a	1	Using index2	DEPENDENT SUBQUERY	t1	ALL	NULL	NULL	NULL	NULL	3	Using whereWarnings:Note	1003	select `test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (not(<in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 AS `Not_used` from `test`.`t1` where ((<cache>(`test`.`t2`.`b`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`)) having <is_not_null_test>(`test`.`t1`.`a`))))))SELECT a FROM t1, t2 WHERE a=b AND (b NOT IN (SELECT a FROM t1));aSELECT a FROM t1, t2 WHERE a=b AND (b NOT IN (SELECT a FROM t1 WHERE a > 4));a14DROP TABLE t1,t2;CREATE TABLE t1 (id int);CREATE TABLE t2 (id int PRIMARY KEY);CREATE TABLE t3 (id int PRIMARY KEY, name varchar(10));INSERT INTO t1 VALUES (2), (NULL), (3), (1);INSERT INTO t2 VALUES (234), (345), (457);INSERT INTO t3 VALUES (222,'bbb'), (333,'ccc'), (111,'aaa');EXPLAINSELECT * FROM t1WHERE t1.id NOT IN (SELECT t2.id FROM t2,t3 WHERE t3.name='xxx' AND t2.id=t3.id);id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	4	Using where2	DEPENDENT SUBQUERY	t2	eq_ref	PRIMARY	PRIMARY	4	func	1	Using where; Using index; Full scan on NULL key2	DEPENDENT SUBQUERY	t3	eq_ref	PRIMARY	PRIMARY	4	func	1	Using where; Full scan on NULL keySELECT * FROM t1WHERE t1.id NOT IN (SELECT t2.id FROM t2,t3 WHERE t3.name='xxx' AND t2.id=t3.id);id2NULL31SELECT (t1.id IN (SELECT t2.id FROM t2,t3 WHERE t3.name='xxx' AND t2.id=t3.id)) AS xFROM t1;x0000DROP TABLE t1,t2,t3;CREATE TABLE t1 (a INT NOT NULL);INSERT INTO t1 VALUES (1),(-1), (65),(66);CREATE TABLE t2 (a INT UNSIGNED NOT NULL PRIMARY KEY);INSERT INTO t2 VALUES (65),(66);SELECT a FROM t1 WHERE a NOT IN (65,66);a1-1SELECT a FROM t1 WHERE a NOT IN (SELECT a FROM t2);a1-1EXPLAIN SELECT a FROM t1 WHERE a NOT IN (SELECT a FROM t2);id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	4	Using where2	DEPENDENT SUBQUERY	t2	unique_subquery	PRIMARY	PRIMARY	4	func	1	Using indexDROP TABLE t1;End of 5.0 tests

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?