日期:2014-05-18 浏览次数:20597 次
if object_id('[A]') is not null drop table [A]
go
create table [A]([序号] int,[A1] int,[B1] int,[C1] int,[D1] int)
insert [A]
select 1,1,2,6,7 union all
select 2,4,7,3,2 union all
select 3,0,9,2,1 union all
select 4,1,2,3,4
go
if object_id('[B]') is not null drop table [B]
go
create table [B]([日期] varchar(2),[A1] int,[B1] int,[C1] int,[D1] int)
insert [B]
select '06',5,2,4,7 union all
select '09',1,2,3,8 union all
select '11',8,2,7,2 union all
select '12',3,1,6,5
go
SELECT *
FROM A
WHERE EXISTS(SELECT 1 FROM B WHERE A1=A.A1 AND B1=A.B1 AND C1=A.C1)
/**
序号 A1 B1 C1 D1
----------- ----------- ----------- ----------- -----------
4 1 2 3 4
(1 行受影响)
**/