[英]How can I select two tables in MySQL but only select one column from the 2nd table?
[英]how can i select two columns from a table and combine the values into one column
我有一个名为tbl_products的表,我想将列start_date和end_date组合成一个名为dates的列,但是两列中的所有值都显示在一个单独的行上。 我已经查看了concat,但所有这一切都是将每列中的两个列组合在一起。
样本数据:
tbl_products.start_date
------------------------
10/1/2011
10/2/2011
10/3/2011
10/4/2011
tbl_products.end_date
----------------------
11/1/2011
11/2/2011
11/3/2011
11/4/2011
然后他们合并后的结果将是
tbl_products.dates
-------------------
10/1/2011
10/2/2011
10/3/2011
10/4/2011
11/1/2011
11/2/2011
11/3/2011
11/4/2011
我在网上看了一遍,不知道我怎么能做到这一点。 任何线索怎么样?
select tbl_products.start_date from tbl_products
union
select tbl_products.end_date from tbl_products
SELECT tbl_products.start_date FROM tbl_products
UNION ALL
SELECT tbl_products.end_date FROM tbl_products
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.