Yevgen
Yevgen

Reputation: 101

Need a query to do the table from two table with common and not common columns

I have two tables with multiples row. Table 1 has a few rows which Table 2 no has. And the opposite.

enter image description here

I need a query which will make a follow table from Table 1 and 2 and sort by ID. Rows Opt3 and Opt4 can be ignored. As below:

enter image description here

How to do a query with SELECT right?

Upvotes: 0

Views: 22

Answers (1)

Nick
Nick

Reputation: 147196

Something like this should work:

(SELECT Id, Question, Answer, Descr, Opt1, NULL AS Opt2
 FROM Table_1)
UNION
(SELECT Id, Question, Answer, Descr, NULL, Opt2
 FROM Table_2)
ORDER BY Id

Upvotes: 1

Related Questions