合并一些列

时间:2014-02-15 04:23:45

标签: mysql concatenation concat

我正在尝试从包含多个列的表(称为地址)返回信息。物理地址分为line1,line2,city,state等。我想显示表中的所有列,但希望将line1和line2列合并为一个名为street的列。

有没有办法在不列出表格中的每一列的情况下执行此操作?

3 个答案:

答案 0 :(得分:0)

试试这个

SELECT Line1 + ',' + Line2, city, state From Address

<强>(OR)

SELECT concat(line1, ' , ', line2) , city, state From Address

答案 1 :(得分:0)

SELECT line1 + line2 AS street, city, state FROM addresses

答案 2 :(得分:0)

试试这个..

SELECT Line1 + ',' + Line2 as Street, city, state From [TableName]