开发者

SQL Two fields from tables of unassociated data into the same field?

开发者 https://www.devze.com 2023-02-03 11:57 出处:网络
I am trying to do this is SQL: ------------------------------- Table A ------------------------------- ID | Title

I am trying to do this is SQL:

-------------------------------
Table A
-------------------------------
ID | Title
1  | Something Groovy
2  | Something Else

-------------------------------
Table B
----------开发者_Python百科---------------------
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. If you want to eliminate duplicates, use simply 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消