2012-10-29 4 views
0

난 2 테이블을 사용하여 모든 데이터를 표시해야합니다.완전 외부 조인은 어떻게 사용할 수 있습니까?

시험

표 연락

numCode | fullName 
00001 | Midna 
00002 | Klog 
00003 | Porla 
00004 | Seka 
00005 | Mila 

표 dateFile

numCode | dateCurr 
00001 | 2012-10-29 00:00:00.000 
00002 | 2012-10-29 00:00:00.000 
00005 | 2012-10-29 00:00:00.000 

코드 SQL 서버

012 3,516,
SELECT df.numCode as 'numCode', tf.dateCurr as 'dateCurr' 
FROM dateFile df Full Outer join Contact ct On ct.numCode = df.numCode 
WHERE df.dateCurr = '2012-10-29' 

출력

numCode | dateCurr 
00001 | 2012-10-29 00:00:00.000 
00002 | 2012-10-29 00:00:00.000 
00005 | 2012-10-29 00:00:00.000 

하지만 출력 GET 필요합니다

numCode | dateCurr 
00001 | 2012-10-29 00:00:00.000 
00002 | 2012-10-29 00:00:00.000 
00003 | 2012-10-29 00:00:00.000 (Insert Date from choose datetime) 
00004 | 2012-10-29 00:00:00.000 (Insert Date from choose datetime) 
00005 | 2012-10-29 00:00:00.000 

답변

1

시도 :

SELECT df.numCode as 'numCode', 
     coalesce(tf.dateCurr, '2012-10-29') as 'dateCurr' 
FROM dateFile df Full Outer join Contact ct 
On ct.numCode = df.numCode and df.dateCurr = '2012-10-29' 
+0

감사합니다. 이 일 ;) – nettoon493

0

이 시도 :

select c.numCode,ISNULL(d.dateCurr,'2012-10-29 00:00:00.000') from Contact c left join dateFile d 
on c.numCode = d.numCode 
관련 문제