日期:2014-05-18 浏览次数:20817 次
declare @main table ( id int ,level int, rate int ) insert into @main select 2007,1,20 insert into @main select 2008,1,30 declare @db table ( id int ,one int, two int ) insert into @db select 2007,1,3 insert into @db select 2007,2,4 insert into @db select 2007,5,1 insert into @db select 2008,2,5 insert into @db select 2007,4,5 select m.id,m.level,b.one,b.two from @main m left join @db b on m.id=b.id where b.one>1 and b.two>1 /******************************** id level one two ----------- ----------- ----------- ----------- 2007 1 2 4 2008 1 2 5 2007 1 4 5 ********************************/