假设我们有如下表格:
table1:
**t1** **t2** **t3**
abc xyz aaa
我可以这样做:
select * from(
(select t.t1,t.t2,t.t3 from table1 t) as tmp
union
(select tmp2.t1,'someothervalue' as t2,tmp2.t3 from tmp tmp2)) as result
order by result.t1
基本上与第一个tmp表本身的联合操作。 假设t1,t2,t3都是varchar类型。
答案 0 :(得分:1)
from tmp tmp2
是不可能的,而不是你可以使用from table1 tmp2
,更新的Sql查询
SELECT * FROM(
SELECT t.t1,t.t2,t.t3 FROM table1 t
UNION
SELECT tmp2.t1,'someothervalue' as t2,tmp2.t3 FROM table1 tmp2
) as result
ORDER BY result.t1