开发者

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
----------开发者_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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜