📄 ndb_subquery.result
字号:
drop table if exists t1;drop table if exists t2;create table t1 (p int not null primary key, u int not null, o int not null,unique (u), key(o)) engine=ndb;create table t2 (p int not null primary key, u int not null, o int not null,unique (u), key(o)) engine=ndb;insert into t1 values (1,1,1),(2,2,2),(3,3,3);insert into t2 values (1,1,1),(2,2,2),(3,3,3), (4,4,4), (5,5,5);explain select * from t2 where p NOT IN (select p from t1);id select_type table type possible_keys key key_len ref rows Extra1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using where2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 Using indexselect * from t2 where p NOT IN (select p from t1) order by p;p u o4 4 45 5 5explain select * from t2 where p NOT IN (select u from t1);id select_type table type possible_keys key key_len ref rows Extra1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using where2 DEPENDENT SUBQUERY t1 unique_subquery u u 4 func 1 Using indexselect * from t2 where p NOT IN (select u from t1) order by p;p u o4 4 45 5 5explain select * from t2 where p NOT IN (select o from t1);id select_type table type possible_keys key key_len ref rows Extra1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using where2 DEPENDENT SUBQUERY t1 index_subquery o o 4 func 1 Using indexselect * from t2 where p NOT IN (select o from t1) order by p;p u o4 4 45 5 5explain select * from t2 where p NOT IN (select p+0 from t1);id select_type table type possible_keys key key_len ref rows Extra1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using where2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 Using whereselect * from t2 where p NOT IN (select p+0 from t1) order by p;p u o4 4 45 5 5drop table t1;drop table t2;create table t1 (p int not null primary key, u int not null) engine=ndb;insert into t1 values (1,1),(2,2),(3,3);create table t2 as select t1.*from t1 as t1, t1 as t2, t1 as t3, t1 as t4, t1 as t5, t1 as t6, t1 as t7, t1 as t8where t1.u = t2.uand t2.u = t3.uand t3.u = t4.uand t4.u = t5.uand t5.u = t6.uand t6.u = t7.uand t7.u = t8.u;select * from t2 order by 1;p u1 12 23 3drop table t1;drop table t2;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -