【发布时间】:2010-05-14 10:08:13
【问题描述】:
我有两张相同的桌子。 我需要以这种方式联合它们:
SELECT f1,f2, xxx
FROM
(SELECT *
FROM tbl1
UNION ALL
SELECT *
FROM tbl2)
其中 xxx 将查询表名,其中 f1 和 f2 字段取自。 示例输出:
123 345 'tbl1' -- this rows are from the first table
121 345 'tbl1'
121 345 'tbl1'
123 345 'tbl1'
124 345 'tbl1'
125 345 'tbl2' -- this rows are from the second table
127 345 'tbl2'
提前谢谢你。
【问题讨论】: