求助:
两个表a和b,两表中的数据几乎相同,b表比a表多几十条数据,求找出多出的数据的语句
两表中的字段是 ID ,NAME,SEX
select * from b
where b.ID not in (select ID from a)
请求其他语句!(注:b表是临时表,是通过其他查询的临时表)
求助:
两个表a和b,两表中的数据几乎相同,b表比a表多几十条数据,求找出多出的数据的语句
两表中的字段是 ID ,NAME,SEX
select * from b
where b.ID not in (select ID from a)
请求其他语句!(注:b表是临时表,是通过其他查询的临时表)
2007-11-14 15:32
create table #t1(
id int,
col1 int,
col2 int
)
insert into #t1 values(1,27,3)
insert into #t1 values(2,22,3)
insert into #t1 values(3,22,3)
insert into #t1 values(4,23,3)
insert into #t1 values(5,3,3)
create table #t2(
id int,
col1 int,
col2 int
)
insert into #t2 values(1,27,3)
insert into #t2 values(2,22,3)
insert into #t2 values(3,22,3)
insert into #t2 values(4,23,3)
insert into #t2 values(5,3,3)
--这两行是多出来的.
insert into #t2 values(7,23,3)
insert into #t2 values(8,3,3)
select b.* from #t1 a full join #t2 b on a.id=b.id where a.id is null
drop table #t1,#t2
/*
id col1 col2
----------- ----------- -----------
7 23 3
8 3 3
*/

2007-11-14 19:36
2007-11-15 08:45
2007-11-15 12:48
2007-11-15 12:54
select b.* from #t1 a full join #t2 b on a.id=b.id where a.id is null
drop table #t1,#t2
为什么最后要删除两个表啊!!!
2007-11-20 13:09
2007-11-20 13:10
2007-11-20 13:15
full
n.
全部, 完整
adj.
充满的, 完全的, 丰富的, 完美的, 详尽的, 丰满的
adv.
完全地, 整整, 十分
哈哈...竟教起英国历史来了.

2007-11-20 16:53
2007-11-20 17:50