2017-08-30 48 views
-6

我需要help爲腳本如何在一個使用SQL加入3列。我想要在結果窗口中加入列address_1address_2address_3如何在SQL Server Management Studio中連接3列?

+0

加入他們在結果窗口?那是什麼意思?你希望他們顯示爲1列? – Veljko89

+0

你到目前爲止嘗試過什麼?請出示你的! –

+0

是的,我希望他們在一列中顯示。這是我目前的腳本。通過cust_name asc從a_customer order中選擇cust_code,cust_name,address_1,address_2,address_3,address_4,telephone 我想加入1列address_1,address_2,address_3,address_4 – Nico

回答

1

看來你正在尋找一個concat運營商如下。

SELECT cust_code, 
     cust_name, 
     address_1 + address_2 + address_3 + address_4, 
     telephone 
FROM a_customer 
ORDER BY cust_name ASC; 

您可以查看演示here

+0

謝謝布羅迪。 – Nico

0
SELECT 
cust_code, 
cust_name, 
address_1 + address_2 + address_3 AS full_address, 
address_4, 
telephone 
FROM 
a_customer 
ORDER BY 
cust_name ASC 

請參閱string concatenation的文檔。

+0

謝謝你。你救了我。 – Nico

0

看來你是如下尋找毗連運算。

SELECT CUST_CODE, CUST_NAME, ADDRESS_1 + address_2 + address_3 + address_4, 電話 FROM a_customer ORDER BY CUST_NAME ASC

相關問題