How to concat multiple columns in sql

时间:2017-08-05 11:53:02

标签: mysql

SELECT  EMP_HOUSE_NO,EMP_STREET_NAME,EMP_AREA,EMP_PIN_CODE

 FROM EMPLOYEE_DETAILS

 WHERE EMP_ID=1;

I need to concat these columns as address

3 个答案:

答案 0 :(得分:0)

Try This select concat (EMP_HOUSE_NO,' ',EMP_STREET_NAME,' ',EMP_AREA,' ',EMP_PIN_CODE) as address from EMPLOYEE_DETAILS WHERE EMP_ID=1;

答案 1 :(得分:0)

If you want spaces between the components, I would suggest concat_ws():

SELECT CONCAT_WS(' ', EMP_HOUSE_NO, EMP_STREET_NAME, EMP_AREA, EMP_PIN_CODE)
FROM EMPLOYEE_DETAILS
WHERE EMP_ID = 1;

答案 2 :(得分:-1)

SELECT CONCAT(EMP_HOUSE_NO,' ', EMP_STREET_NAME,' ', EMP_AREA) AS address

from EMPLOYEE_DETAILS

WHERE EMP_ID=1;