给定此表:
id foo bar
1 a d
2 b e
3 c f我想合并foo和bar colum,这样我就有了它们的所有值的结果集:
预期结果:
a
b
c
d
e
f我的搜索结果是this question,但它的答案是关于通过以下方式连接字段:
select CONCAT(foo, bar) as foobar from MyTable为我生成错误的输出:
ad
be
cf我不想合并,但我想合并这两列。
如何获得foo栏两个字段的所有值的结果?
发布于 2018-09-05 17:30:44
使用UNION
SELECT foo as new_col FROM MyTable
UNION
SELECT bar FROM MyTable或者UNION ALL,如果你对副本感兴趣的话。
https://stackoverflow.com/questions/52181721
复制相似问题