2013-05-06 57 views
0

我試圖創建一個mysql視圖,將多個值從一個表中拉入視圖中的一列。我想對於使用後綴,這樣我可以管理任何給定的別名添加和刪除更好的別名表不同的方法MySql視圖,其中一列是來自表列的數組

[email protected]   [email protected] 
[email protected]   [email protected] 
[email protected]   [email protected] 

查看

[email protected]  [email protected],[email protected] 
[email protected]  [email protected] 

會是什麼mysql的視圖代碼是創建這個視圖?感謝您的時間和響應

回答

0

創建表:

create table email (
    id serial, 
    address varchar(254), 
    alias varchar(254) 
); 

SELECT語句:

select group_concat(address) as addresses, alias 
from email 
group by alias; 

創建視圖:

create view aliases as 
select group_concat(address) as addresses, alias 
from email group by alias; 
+0

感謝您的指導 – 2013-05-06 22:30:36

相關問題