我需要在 select 语句中显示表名。如何?
确切的问题:
我们在两个表中有公共列。我们正在使用以下方式显示记录
select column_name from table_name_1
union
select column_name from table_name_2
但要求是,我们需要将源 table_name 与数据一起显示。
考虑 a、c 存在于 table_1 中,b、d 存在于 table_2 中。
我们需要以下方式的输出
eg:
column_name table_name
a table_1
b table_2
c table_1
d table_2
.......................................................
......................................................
这可能吗
select 'table1', * from table1
union
select 'table2',* from table2
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)