简体   繁体   English

mysql 组合两列

[英]mysql combining two columns

I need a little help in mysql.我需要 mysql 的一点帮助。 I have a table(say tablea ) like this我有一张像这样的桌子(比如tablea

tablea
--------------------------------------------
col1                         col2
a                            1
b                            1
c                            1
h                            3
d                            2
e                            2
f                            2
--------------------------------------------

After combining, my output should be组合后,我的output应该是

col3
--------
1
a
b
c
3
h
2
d
e
f
--------

Any idea on how to get this output?关于如何获得这个 output 的任何想法?

Use the UNION operator, like so:使用UNION运算符,如下所示:

SELECT col1 AS col3
FROM tablea

UNION ALL

SELECT col2 AS col3
FROM tablea

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM