我有 3 个表,如下面的屏幕截图所示。我使用 UNION 创建了一个查询,如下所示。
SELECT T1_ID AS ID, T1_NAME AS NAME, T1_ADD AS ADDRESS
FROM Table1
UNION
SELECT T2_ID AS ID, T2_NAME AS NAME, T2_ADD AS ADDRESS
FROM Table2
UNION
SELECT T3_ID AS ID, T3_NAME AS NAME, T3_ADD AS ADDRESS
FROM Table3
我得到了下面的结果。
我的问题是,如何添加一个名为 TYPE 的列(字段)并为查询结果赋值,但不更新现有的三个表以使其像下面的屏幕截图一样?