我希望能够选择行所在的表的名称作为联合选择查询中的列.像这样的东西:
SELECT [TABLENAME], text from table1
UNION
SELECT [TABLENAME], text from table2
ORDER BY date
Run Code Online (Sandbox Code Playgroud)
有谁知道这是否可能?谢谢
你已经在那张桌子上查询了.例如: - table1和table2
所以你基本上可以输出表名作为字符串本身 -
SELECT 'table1' as tableName, text from table1
UNION
SELECT 'table2' as tableName, text from table2
ORDER BY date
Run Code Online (Sandbox Code Playgroud)