concatenate two database columns into one resultset column

后端 未结 7 2180
独厮守ぢ
独厮守ぢ 2020-11-28 10:00

I use the following SQL to concatenate several database columns from one table into one column in the result set:

SELECT (field1 + \'\' + field2 + \'\' + field

7条回答
  •  一生所求
    2020-11-28 10:08

    If you are having a problem with NULL values, use the COALESCE function to replace the NULL with the value of your choice. Your query would then look like this:

    SELECT (COALESCE(field1, '') + '' + COALESCE(field2, '') + '' + COALESCE(field3,'')) FROM table1
    

    http://www.codeproject.com/KB/database/DataCrunching.aspx

提交回复
热议问题