Join two tables with the same column into a value in one

I have tables like this:

Table Articles
---------------
AID(PK)   Name   PublisherID   Words


Table Books
---------------
BID(PK)   Title  PublisherID   Date

I want to combine them as:

Table Total
---------------
Title   PublisherID

In this new table, Name in the table. Articles will belong to the Heading column because .. Articles. Name and books. The title means the same thing :)

Any answers would be much appreciated :)

thanks

+3
source share
2 answers
select title, publisherid from books
union all
select name, publisherid from articles
+6
source

As I understand it, you are looking for the result:

select name, publisherId
from TableArticles
union 
select title, publisherId
from TableBooks
+1
source

Source: https://habr.com/ru/post/1712461/


All Articles