I know it sounds easy when appending a entire row to new table, but this is different
Question 1, state to combine the Table 1 and Table 2 and keep duplicate value, to create a new table, I have used the following query:
CREATE TABLE EMP_TBL_3
(
EMP_ID int,
Name varchar(255),
DOJ int
);
INSERT INTO EMP_TBL_3 (EMP_ID, Name, DOJ)
SELECT * FROM EMP_TBL_1
UNION ALL
SELECT * FROM EMP_TBL_2;
Results:
Now the problem arise at 2nd question, saying: Take the D.O.B from EMP_BRTH_REC and combine them to EMP_TBL_3:
I have tried this query:
ALTER TABLE EMP_TBL_3
ADD DOB int;
SELECT * FROM EMP_TBL_3;
SELECT EMP_ID, Name, DOJ, DOB
FROM EMP_TBL_3
UNION ALL
SELECT EMP_TBL_3.EMP_ID, EMP_TBL_3.Name, EMP_TBL_3.DOJ, EMP_BRTH_REC.DOB
FROM EMP_BRTH_REC
LEFT JOIN EMP_TBL_3 ON EMP_BRTH_REC.EMP_ID = EMP_TBL_3.EMP_ID;
Results:
My desired output is:
How do I do that?





