简体   繁体   中英

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

I am trying to do this is 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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