[英]SQL Two fields from tables of unassociated data into the same field?
I am trying to do this is SQL: 我正在尝试使用SQL:
-------------------------------
Table A
-------------------------------
ID | Title
1 | Something Groovy
2 | Something Else
-------------------------------
Table B
-------------------------------
ID | Title
1 | Something Different
2 | Something More
Awesome Select Statement 精选声明
-------------------------------
Both in one field
-------------------------------
Title
Something Groovy
Something Else
Something Different
Something More
Any Ideas? 有任何想法吗?
Use UNION ALL
to obtain the union of two selects. 使用
UNION ALL
获得两个选择的并集。 If you want to eliminate duplicates, use simply UNION
. 如果要消除重复项,只需使用
UNION
。
SELECT Title FROM TableA
UNION ALL
SELECT Title FROM TableB
This is a simple union: 这是一个简单的联合:
Select title from TableA
UNION
Select title from TableB
Note that any items that are identical will be eliminated. 请注意,所有相同的项目都将被删除。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.