mysql结果集导出Excel,convert(c.name using gb2312)--中文不乱码,a.xls在安装根目录下
select convert(c.name using gb2312), convert(c.status using gb2312), convert(c.type using gb2312), convert(c.company using gb2312) into outfile '/a.xls' from (select a.name name, CASE when a.status = 1 then '未完成' when a.status = 2 then '完成' else '其他' END status, CASE when a.type = 1 then '银行' when a.type = 2 then '国企' else '其他' END type, b.name company from t_product a,t_company b where a.cid=b.id order by a.type ,a.status) c