join_nested.result
来自「视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.」· RESULT 代码 · 共 1,747 行 · 第 1/4 页
RESULT
1,747 行
FROM t0,t1LEFT JOIN ( t2LEFT JOIN (t3, t4)ON t3.a=1 AND t2.b=t4.b,t5 LEFT JOIN ( (t6, t7)LEFT JOIN t8ON t7.b=t8.b AND t6.b < 10)ON t6.b >= 2 AND t5.b=t7.b )ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND(t1.a != 2),t9WHERE t0.a=1 ANDt0.b=t1.b AND (t2.a >= 4 OR t2.c IS NULL) AND(t3.a < 5 OR t3.c IS NULL) AND(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND(t5.a >=2 OR t5.c IS NULL) AND(t6.a >=4 OR t6.c IS NULL) AND(t7.a <= 2 OR t7.c IS NULL) AND(t8.a < 1 OR t8.c IS NULL) AND(t8.b=t9.b OR t8.c IS NULL) AND(t9.a=1);id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t0 ALL NULL NULL NULL NULL 3 Using where1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using where1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where1 SIMPLE t7 ALL NULL NULL NULL NULL 2 Using where1 SIMPLE t6 ALL NULL NULL NULL NULL 3 Using where1 SIMPLE t8 ALL NULL NULL NULL NULL 2 Using where1 SIMPLE t9 ALL NULL NULL NULL NULL 3 Using whereWarnings:Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))CREATE INDEX idx_b ON t4(b);CREATE INDEX idx_b ON t5(b);EXPLAIN EXTENDEDSELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.bFROM t0,t1LEFT JOIN ( t2LEFT JOIN (t3, t4)ON t3.a=1 AND t2.b=t4.b,t5 LEFT JOIN ( (t6, t7)LEFT JOIN t8ON t7.b=t8.b AND t6.b < 10)ON t6.b >= 2 AND t5.b=t7.b )ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND(t1.a != 2),t9WHERE t0.a=1 ANDt0.b=t1.b AND (t2.a >= 4 OR t2.c IS NULL) AND(t3.a < 5 OR t3.c IS NULL) AND(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND(t5.a >=2 OR t5.c IS NULL) AND(t6.a >=4 OR t6.c IS NULL) AND(t7.a <= 2 OR t7.c IS NULL) AND(t8.a < 1 OR t8.c IS NULL) AND(t8.b=t9.b OR t8.c IS NULL) AND(t9.a=1);id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t0 ALL NULL NULL NULL NULL 3 Using where1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where1 SIMPLE t4 ref idx_b idx_b 5 test.t2.b 2 Using where1 SIMPLE t5 ALL idx_b NULL NULL NULL 3 Using where1 SIMPLE t7 ALL NULL NULL NULL NULL 2 Using where1 SIMPLE t6 ALL NULL NULL NULL NULL 3 Using where1 SIMPLE t8 ALL NULL NULL NULL NULL 2 Using where1 SIMPLE t9 ALL NULL NULL NULL NULL 3 Using whereWarnings:Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))CREATE INDEX idx_b ON t8(b);EXPLAIN EXTENDEDSELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.bFROM t0,t1LEFT JOIN ( t2LEFT JOIN (t3, t4)ON t3.a=1 AND t2.b=t4.b,t5 LEFT JOIN ( (t6, t7)LEFT JOIN t8ON t7.b=t8.b AND t6.b < 10)ON t6.b >= 2 AND t5.b=t7.b )ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND(t1.a != 2),t9WHERE t0.a=1 ANDt0.b=t1.b AND (t2.a >= 4 OR t2.c IS NULL) AND(t3.a < 5 OR t3.c IS NULL) AND(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND(t5.a >=2 OR t5.c IS NULL) AND(t6.a >=4 OR t6.c IS NULL) AND(t7.a <= 2 OR t7.c IS NULL) AND(t8.a < 1 OR t8.c IS NULL) AND(t8.b=t9.b OR t8.c IS NULL) AND(t9.a=1);id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t0 ALL NULL NULL NULL NULL 3 Using where1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where1 SIMPLE t4 ref idx_b idx_b 5 test.t2.b 2 Using where1 SIMPLE t5 ALL idx_b NULL NULL NULL 3 Using where1 SIMPLE t7 ALL NULL NULL NULL NULL 2 Using where1 SIMPLE t6 ALL NULL NULL NULL NULL 3 Using where1 SIMPLE t8 ref idx_b idx_b 5 test.t5.b 2 Using where1 SIMPLE t9 ALL NULL NULL NULL NULL 3 Using whereWarnings:Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))CREATE INDEX idx_b ON t1(b);CREATE INDEX idx_a ON t0(a);EXPLAIN EXTENDEDSELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.bFROM t0,t1LEFT JOIN ( t2LEFT JOIN (t3, t4)ON t3.a=1 AND t2.b=t4.b,t5 LEFT JOIN ( (t6, t7)LEFT JOIN t8ON t7.b=t8.b AND t6.b < 10)ON t6.b >= 2 AND t5.b=t7.b )ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND(t1.a != 2),t9WHERE t0.a=1 ANDt0.b=t1.b AND (t2.a >= 4 OR t2.c IS NULL) AND(t3.a < 5 OR t3.c IS NULL) AND(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND(t5.a >=2 OR t5.c IS NULL) AND(t6.a >=4 OR t6.c IS NULL) AND(t7.a <= 2 OR t7.c IS NULL) AND(t8.a < 1 OR t8.c IS NULL) AND(t8.b=t9.b OR t8.c IS NULL) AND(t9.a=1);id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t0 ref idx_a idx_a 5 const 1 Using where1 SIMPLE t1 ref idx_b idx_b 5 test.t0.b 2 Using where1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where1 SIMPLE t4 ref idx_b idx_b 5 test.t2.b 2 Using where1 SIMPLE t5 ALL idx_b NULL NULL NULL 3 Using where1 SIMPLE t7 ALL NULL NULL NULL NULL 2 Using where1 SIMPLE t6 ALL NULL NULL NULL NULL 3 Using where1 SIMPLE t8 ref idx_b idx_b 5 test.t5.b 2 Using where1 SIMPLE t9 ALL NULL NULL NULL NULL 3 Using whereWarnings:Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.bFROM t0,t1LEFT JOIN ( t2LEFT JOIN (t3, t4)ON t3.a=1 AND t2.b=t4.b,t5 LEFT JOIN ( (t6, t7)LEFT JOIN t8ON t7.b=t8.b AND t6.b < 10)ON t6.b >= 2 AND t5.b=t7.b )ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND(t1.a != 2),t9WHERE t0.a=1 ANDt0.b=t1.b AND (t2.a >= 4 OR t2.c IS NULL) AND(t3.a < 5 OR t3.c IS NULL) AND(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND(t5.a >=2 OR t5.c IS NULL) AND(t6.a >=4 OR t6.c IS NULL) AND(t7.a <= 2 OR t7.c IS NULL) AND(t8.a < 1 OR t8.c IS NULL) AND(t8.b=t9.b OR t8.c IS NULL) AND(t9.a=1);a b a b a b a b a b a b a b a b a b a b1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 11 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 11 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 11 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 11 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 11 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 11 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 11 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 21 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 21 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 1 21 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 21 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 21 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 1 21 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 21 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 21 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 1 21 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 2SELECT t2.a,t2.bFROM t2;a b3 34 25 3SELECT t3.a,t3.bFROM t3;a b1 22 2SELECT t2.a,t2.b,t3.a,t3.bFROM t2 LEFT JOIN t3 ON t2.b=t3.bWHERE t2.a = 4 OR (t2.a > 4 AND t3.a IS NULL);a b a b4 2 1 24 2 2 25 3 NULL NULLSELECT t2.a,t2.b,t3.a,t3.bFROM t2 LEFT JOIN (t3) ON t2.b=t3.bWHERE t2.a = 4 OR (t2.a > 4 AND t3.a IS NULL);a b a b4 2 1 24 2 2 25 3 NULL NULLALTER TABLE t3CHANGE COLUMN a a1 int,CHANGE COLUMN c c1 int;SELECT t2.a,t2.b,t3.a1,t3.bFROM t2 LEFT JOIN t3 ON t2.b=t3.bWHERE t2.a = 4 OR (t2.a > 4 AND t3.a1 IS NULL);a b a1 b4 2 1 24 2 2 25 3 NULL NULLSELECT t2.a,t2.b,t3.a1,t3.bFROM t2 NATURAL LEFT JOIN t3WHERE t2.a = 4 OR (t2.a > 4 AND t3.a1 IS NULL);a b a1 b4 2 1 24 2 2 25 3 NULL NULLDROP TABLE t0,t1,t2,t3,t4,t5,t6,t7,t8,t9;CREATE TABLE t1 (a int);CREATE TABLE t2 (a int);CREATE TABLE t3 (a int);INSERT INTO t1 VALUES (1);INSERT INTO t2 VALUES (2);INSERT INTO t3 VALUES (2);INSERT INTO t1 VALUES (2);SELECT * FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON t2.a=t3.a) ON t1.a=t3.a;a a a1 NULL NULL2 2 2SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON t2.a=t3.a ON t1.a=t3.a;a a a1 NULL NULL2 2 2DELETE FROM t1 WHERE a=2;SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON t2.a=t3.a ON t1.a=t3.a;a a a1 NULL NULLDELETE FROM t2;SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON t2.a=t3.a ON t1.a=t3.a;a a a1 NULL NULLDROP TABLE t1,t2,t3;CREATE TABLE t1(a int, key (a));CREATE TABLE t2(b int, key (b));CREATE TABLE t3(c int, key (c));INSERT INTO t1 VALUES (NULL), (0), (1), (2), (3), (4), (5), (6), (7), (8), (9),(10), (11), (12), (13), (14), (15), (16), (17), (18), (19);INSERT INTO t2 VALUES (NULL), (0), (1), (2), (3), (4), (5), (6), (7), (8), (9),(10), (11), (12), (13), (14), (15), (16), (17), (18), (19);INSERT INTO t3 VALUES (0), (1), (2), (3), (4), (5);EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON c < 3 and b = c;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 index NULL a 5 NULL 21 Using index1 SIMPLE t3 index c c 5 NULL 6 Using index1 SIMPLE t2 ref b b 5 test.t3.c 2 Using indexEXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 index NULL a 5 NULL 21 Using index1 SIMPLE t3 index c c 5 NULL 6 Using index1 SIMPLE t2 ref b b 5 test.t3.c 2 Using indexSELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c;a b cNULL 0 0NULL 1 1NULL 2 20 0 00 1 10 2 21 0 01 1 11 2 22 0 02 1 12 2 23 0 03 1 13 2 24 0 04 1 14 2 25 0 05 1 15 2 26 0 06 1 16 2 27 0 07 1 17 2 28 0 08 1 18 2 29 0 09 1 19 2 210 0 010 1 110 2 211 0 011 1 111 2 212 0 012 1 112 2 213 0 013 1 113 2 214 0 014 1 114 2 215 0 015 1 115 2 216 0 016 1 116 2 217 0 017 1 117 2 218 0 018 1 118 2 219 0 019 1 119 2 2DELETE FROM t3;EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 index NULL a 5 NULL 21 Using index1 SIMPLE t3 index c c 5 NULL 0 Using index1 SIMPLE t2 ref b b 5 test.t3.c 2 Using indexSELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c;a b cNULL NULL NULL0 NULL NULL1 NULL NULL2 NULL NULL3 NULL NULL4 NULL NULL5 NULL NULL6 NULL NULL7 NULL NULL8 NULL NULL9 NULL NULL10 NULL NULL11 NULL NULL12 NULL NULL13 NULL NULL14 NULL NULL15 NULL NULL16 NULL NULL17 NULL NULL18 NULL NULL19 NULL NULLDROP TABLE t1,t2,t3;CREATE TABLE t1 (c11 int);CREATE TABLE t2 (c21 int);CREATE TABLE t3 (c31 int);INSERT INTO t1 VALUES (4), (5);SELECT * FROM t1 LEFT JOIN t2 ON c11=c21;c11 c214 NULL5 NULLEXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON c11=c21;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 system NULL NULL NULL NULL 0 const row not found
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?