2012-04-25 74 views

回答

0

如何嘗試這樣的事情

SELECT TBL1.ID, 
TBL1.COUNTRY As A, 
TBL1.STATE As B, 
TBL1.CODE As C 
FROM TBL1 
    INNER JOIN TBL2 ON CAST(TBL1.COUNTRY AS varchar(20)) + '.' + CAST(TBL1.STATE AS varchar(20)) + '.' + CAST(TBL1.CODE AS varchar(20)) = CAST(TBL2.ID AS varchar(20)) 

在組合和比較它們之前添加了將4個字段強制轉換爲varchar的代碼。

+0

我似乎有數據類型的問題,請參閱sql小提琴 – greener 2012-04-25 21:05:47

+0

請參閱下面的解決方案 – Jatin 2012-04-25 21:15:06

0
SELECT T.name,T2.nam FROM 
T INNER JOIN T2 
ON T.id = (T2.one + '.' + CAST(T2.two as varchar(50)) + '.' + CAST(T2.thr as varchar(50)))