Brian Crist
Brian Crist

Reputation: 814

How to join two table with customize column?

I have two table.

I want to select all data from two tables and customize columns as follow (change name column Product_X and Product_Y to Product, add two column Color and Weight,.etc..).

Please see image

enter image description here

I think i should use JOIN, but I still have no idea about this issue.

Upvotes: 0

Views: 50

Answers (1)

Felix Pamittan
Felix Pamittan

Reputation: 31879

You need to use UNION ALL:

SELECT
    Category,
    Product_X AS Product,
    Price,
    Color,
    NULL AS Weight
FROM TableA

UNION ALL

SELECT
    Category,
    Product_Y,
    Price,
    NULL,
    Weight
FROM TableB

Upvotes: 2

Related Questions