Can anyone please help me on how to create view joining two tables having same columns without duplicates?
Example:
I have two tables T1 and T2
T1
Id Name Date
-----------------------
1 AAA 2019-04-05
2 BBB 2019-04-06
3 CCC 2019-04-07
T2
Id Name Date
----------------------
4 DDD 2019-04-01
1 ABC 2019-03-01
2 DEF 2019-03-02
My output view should look like this
Id Name Date
------------------------
1 AAA 2019-04-05 (From T1)
2 BBB 2019-04-06 (From T1)
3 CCC 2019-04-07 (From T1)
4 DDD 2019-04-01 (From T2)
Below is the query I am trying
CREATE VIEW view AS (
(
SELECT
t1.id,
t1.name,
t1.date,
FROM
T1 as t1
UNION
SELECT
t2.id,
t2.name,
t2.date,
FROM
T2 as t2
)
But I get duplicate records.