查询有关将结果导出到excel的sql

时间:2012-03-29 11:54:11

标签: mysql

在此查询中,我尝试将结果导出到csv ...但是我收到错误

  

错误:----每个派生表都必须有自己的别名

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 个答案:

答案 0 :(得分: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;