日期:2014-05-17 浏览次数:20642 次
---------------------------- -- Author :fredrickhu(小F,向高手学习) -- Date :2011-04-06 09:47:40 -- Verstion: -- Microsoft SQL Server 2008 (RTM) - 10.0.1600.22 (Intel X86) -- Jul 9 2008 14:43:34 -- Copyright (c) 1988-2008 Microsoft Corporation -- Enterprise Edition on Windows NT 5.1 <X86> (Build 2600: Service Pack 3) -- ---------------------------- --> 测试数据:[a] if object_id('[a]') is not null drop table [a] go create table [a]([a] int,[b] int) insert [a] select 1,4 union all select 2,5 union all select 3,6 --> 测试数据:[b] if object_id('[b]') is not null drop table [b] go create table [b]([a] int,[b] int) insert [b] select 2,5 union all select 3,6 union all select 4,7 --------------开始查询-------------------------- select * from [a] full join b on a.a=b.a select * from a union all select * from b ----------------结果---------------------------- /* a b a b 1 4 NULL NULL 2 5 2 5 3 6 3 6 NULL NULL 4 7 a b 1 4 2 5 3 6 2 5 3 6 4 7 */
------解决方案--------------------