2016-11-08 80 views
0

這是file_tblenter image description here 這是name_tblenter image description here在結合了兩排結果兩列(MySQL的)

我想下面的結果。 enter image description here

select email, file, name 
from file_tbl as ft 
join name_tble as nt on ft.email = nt.email 
where nt appId = 6 

沒有給出期望的結果。

如何實現這一目標?

+1

http://rextester.com/LJZT12227 - 基本上你必須利用GROUP_CONCAT函數在MySQL – Sanj

+0

這工作,但是否有任何其它的方式來獲得這些值在兩列? –

回答

0

這將是東西,你可以使用:

SELECT email,GROUP_CONCAT(DISTINCT file SEPARATOR ','), 
     name from file_tbl 
     as ft join name_tble 
     as nt on ft.email = nt.email 
WHERE 1 
GROUP BY nt.email 
+0

是沒有任何其他方式來獲得這兩個值 –