如何在mysql中将多列值组合为单列

时间:2016-08-22 12:05:29

标签: mysql

您好,我喜欢多列,

Address1, Address2

value1,   value2

我在地址中需要这个单列名称,如下所示

Address

value1
value2

如何使用mysql查询执行此操作?

请有人帮助我......

2 个答案:

答案 0 :(得分:1)

您可以对这两列中的UNION进行操作,将它们放入一列中:

SELECT Address1 AS Address
FROM yourTable
UNION ALL
SELECT Address2 AS Address
FROM yourTable

答案 1 :(得分:1)

您可以使用Union,例如

Select Address1 as Address 
FROM Table 
UNION 
Select Address2 
FROM Table