在您要提取的其他列的列中提供表名称:
SELECT
'table1' AS tablename,
other columns
FROM table1
UNION ALL
SELECT
'table2' AS tablename,
other columns
FROM table2
UNION ALL
…
Run Code Online (Sandbox Code Playgroud)
在结果列表中添加一列,说明数据来自哪个表.例如:
select 'table1' tableName,
columnA,
columnB
from table1
union
select 'table2' tableName,
columnC,
columnD
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3002 次 |
| 最近记录: |