表 T1
SID DD CC
012 89 50
315 88 11
014 99 44
表 T2
SID JJ YY
315 898 852
014 78 221
求 結果 表T1.sid <> T2.SID
SID DD CC
012 89 50
SID DD CC
012 89 50
315 88 11
014 99 44
表 T2
SID JJ YY
315 898 852
014 78 221
求 結果 表T1.sid <> T2.SID
SID DD CC
012 89 50
解决方案 »
- 不使用MAX,MIN和子查询,如何去除重复行
- 谁能解释一下表的所有者,登录名,用户这三者之间的关系?
- SQL Server Analysis Services (MSSQLSERVER)无法启动
- 请问如何强行指定查询语句所执行的索引啊?
- 求sql2000标准版的下载地址 急!
- 请大家帮忙介绍几本适合初学者的 有关 Sql Server 的书籍
- 怎样统计时间??请高手帮忙。
- SQL sever 和 c++ builder 的连接问题(多少分都行)!!!HELP
- 如何返回数学表达式的字符串成运算后的结果!!!急急
- VB代码执行一个*.sql脚本 不用循环去执行,而是我给这个.sql脚本存放的路径,代码调用SQL SERVER2000的查询分析器去执行这个脚本,怎么解
- 存储过程内部变量 全局变量使用
- join table的问题
insert into t1 values('012', 89 ,50)
insert into t1 values('315', 88 ,11)
insert into t1 values('014', 99 ,44 )
create table T2(SID varchar(10),jj int,yy int)
insert into t2 values('315', 898, 852 )
insert into t2 values('014', 78 ,221)goselect t1.* from t1 where sid not in (select sid from t2)
/*
SID DD CC
---------- ----------- -----------
012 89 50(所影响的行数为 1 行)
*/select t1.* from t1 where not exists (select 1 from t2 where t2.sid = t1.sid)
/*
SID DD CC
---------- ----------- -----------
012 89 50(所影响的行数为 1 行)
*/drop table t1 , t2
select t1.* from t1 left join t2 on t1.sid=t2.sid where t2.sid is null
drop table T1create table T1(SID varchar(10),DD int,CC int)
insert into t1 values('012', 89 ,50)
insert into t1 values('315', 88 ,11)
insert into t1 values('014', 99 ,44 )
if object_id('T2') is not null
drop table T2
create table T2(SID varchar(10),jj int,yy int)
insert into t2 values('315', 898, 852 )
insert into t2 values('014', 78 ,221)select * from T1 t where t.SID in ((select sid from T1) except (select sid from T2))
select SID,DD as DDorJJ, CC as CCorYY from t1 where sid not in (select sid from t2)
union
select SID,JJ as DDorJJ, YY as CCorYY from t2 where sid not in (select sid from t1)
--insert into t1 values('012', 89 ,50)
--insert into t1 values('315', 88 ,11)
--insert into t1 values('014', 99 ,44 )
--create table T2(SID varchar(10),jj int,yy int)
--insert into t2 values('315', 898, 852 )
--insert into t2 values('014', 78 ,221)
--insert into t2 values('013', 78 ,221)select * from T1 where sid not in(
select sid from T2
)
union
(
select * from T2 where sid not in(
select sid from T1)
)