34,590
社区成员
发帖
与我相关
我的任务
分享
select * from edepartGeneral where operator in (select operator from edepartdigit )
//(所影响的行数为 88 行)
select * from edepartGeneral as a where exists (select * from edepartdigit as b where a.operator=b.operator)
//(所影响的行数为 88 行)
select * from edepartGeneral where operator in (select operator from edepartdigit ) and ndate in (select ndate from edepartdigit)
//(所影响的行数为 84 行)
select * from edepartGeneral as a where exists (select * from edepartdigit as b where a.operator=b.operator and a.ndate=b.ndate)
//(所影响的行数为 75 行)
create table t1 (c1 int,c2 int);
create table t2 (c1 int,c2 int);
insert into t1 values (1,2);
insert into t1 values (1,3);
insert into t2 values (1,2);
insert into t2 values (1,null);
select * from t1 where c2 not in (select c2 from t2); --返回null
select * from t1 where not exists (select * from t2 where t1.c2=t2.c2); --返回1,3
--上面一句等价于等价于下面一句
select * from t1 where c2 not in (select c2 from t2 where c2 is not null)-- 返回1,3
select * from t1 where c2 not in (select c2 from t2); --返回null
select * from edepartGeneral where operator in (select operator from edepartdigit where ndate in(select ndate from edepartGeneral) )
//(所影响的行数为 90 行)
select * from edepartGeneral where operator='小王'
//(所影响的行数为 90 行)
select distinct * from edepartGeneral where operator='小王'
//(所影响的行数为 90 行)
SQL codeselect * from edepartGeneral where operator in (select operator from edepartdigit where ndate in(select ndate from edepartGeneral) )
//(所影响的行数为 90 行)
SQL codeselect * from edepartGeneral where operator in (select operator from edepartdigit where ndate in(select ndate from edepartGeneral) )
//(所影响的行数为 90 行)
select * from edepartGeneral where operator in (select operator from edepartdigit where ndate in(select * from edepartGeneral) )
ndate operator
2011-09-01 aaa
2011-09-01 aaa
2011-09-02 aaa
2011-09-02 aaa
2011-09-02 aaa
2011-09-03 aaa
2011-09-03 aaa
2011-09-03 aaa
ndate operator
2011-09-01 aaa
2011-09-02 aaa
2011-09-02 aaa
2011-09-03 aaa