1
我有一個查詢分配頭查詢mysql的
select abc from table1 union select def from table2
我想要的結果作爲不同的頁眉來湊錢。
我想
Select * as diff (select abc from table1 union select def from table2)
應該是什麼查詢,以便結果在第三列標題DIFF杵。
感謝
我有一個查詢分配頭查詢mysql的
select abc from table1 union select def from table2
我想要的結果作爲不同的頁眉來湊錢。
我想
Select * as diff (select abc from table1 union select def from table2)
應該是什麼查詢,以便結果在第三列標題DIFF杵。
感謝
如果我理解正確的話,你想在外部查詢到有一個自定義列名。
您可以通過專門引用您想要重命名的列來完成此操作。
下面是一個例子:
create table t (c varchar(10));
create table t2 (c2 varchar(10));
insert into t values ('abc');
insert into t2 values ('def');
select s.c as t
from (
select c
from t
union
select c2
from t2
) s;
結果:
t
---
abc
def
只是用頭別名第一選擇:
select abc as diff from table1 union
select def from table2