2012-03-29 58 views
0

在此查詢我試圖將結果導出爲CSV ...但我得到的錯誤作爲查詢有關SQL關於出口,結果到Excel

error:----Every derived table must have its own alias

SELECT * INTO OUTFILE "c:/mydata.csv" 
FROM (SELECT e.server,e.token,e.datetime,e.workstation,f.surname,f.forename,f.token 
FROM statistic e, USER f 
WHERE e.token=f.token); 

回答

1

嘗試定義您的子查詢的別名:

SELECT * INTO OUTFILE "c:/mydata.csv" 
FROM (SELECT e.server,e.token as stat_token,e.datetime,e.workstation, 
      f.surname,f.forename,f.token as user_token 
     FROM statistic e, 
     USER f 
     WHERE e.token=f.token) as server_statistics; 
+0

現在的錯誤是:---重複的列名稱'令牌' – Raj 2012-03-29 12:16:39

+0

@Raj:請參閱我的更新。這樣列的名稱就不同了。 – 2012-03-29 13:15:20

+0

好的...!非常感謝juergen d :)你能解釋一下嗎?你使用(作爲標記)關鍵字 – Raj 2012-03-30 08:58:45