日期:2014-05-18  浏览次数:20364 次

请问一个连接查询的问题
有表一:
 date product customer 数量
 3.1,A物料, 客户1, 1
 3.1, A物料, 客户1, 4
表二:(表结构和表1一样)
 3.2,A物料,客户1,1
 3.2,B物料,客户1,3
连接条件:date,product,customer一样。
想得到:
 3.1 A物料, 客户1, 1, null ,null, null, null
 3.1 B物料, 客户1, 4, 3.1 B物料,客户1, 3
 null null null null 3.2 A物料 客户1, 1

请问sql该怎么写。
 


------解决方案--------------------
select T1.*,T2.*

T1 full join T2
on T1.date = T2.date and T1.product = T2.product and T1.customer = T2.customer
------解决方案--------------------
select T1.*,T2.*

T1 full out join T2
on T1.date = T2.date and T1.product = T2.product and T1.customer = T2.customer
------解决方案--------------------
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~