Sql 如何在表中动态添加列?
我想添加两个表。但是,我应该如何区分哪些条目来自哪个表呢 表1 表2 结果应该是:Sql 如何在表中动态添加列?,sql,mysql,Sql,Mysql,我想添加两个表。但是,我应该如何区分哪些条目来自哪个表呢 表1 表2 结果应该是: col1 tablename ---------------- a table1 b " c " d table2 e " f " Alis,你没有接受我们之前的答案!解释你自己! 1 2 3 col1 tablename ---------------- a table1 b " c " d table2 e
col1 tablename
----------------
a table1
b "
c "
d table2
e "
f "
Alis,你没有接受我们之前的答案!解释你自己!
1
2
3
col1 tablename
----------------
a table1
b "
c "
d table2
e "
f "
Select Table1.Col1, "Table1" as 'TableName'
From dbo.Table1
Union all
Select Table2.Col1, "Table2" as 'TableName'
From dbo.Table2