I want to create a view with a join of three tables. But as a result of the query, I want one additional column, for example "tableId".
My code is like
CREATE OR REPLACE VIEW DETAILS
AS SELECT
* FROM
(
SELECT
T1.ID,
T1.AMOUNT,
T1.STATUS,
T1.ADDEDBY,
T1.ADDEDON
FROM Table1 T1
UNION ALL
SELECT
T2.ID,
T2.AMOUNT,
T2.STATUS,
T2.ADDEDBY,
T2.ADDEDON
FROM Table2 T2
UNION ALL
SELECT
T3.ID,
T3.BILLAMOUNT,
T3.STATUS,
T3.ADDEDBY,
T3.ADDEDON
FROM Table3 T3
);
This gives me the join of the required three tables. But how can I get the table id column in the given release? This column is missing from any of the three tables.
source
share