欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

[MySQL] 解决mysql导出excel数值型变成科学计数法问题

程序员文章站 2024-03-16 09:01:16
...

当有数据导出需求的时候

我们直接写sql语句就能实现

但是有时候mysql中存储的数值太大了,在excel里面会变成科学计数法,如果超过了64位的话,那么还会丢失精度

需要在sql语句中concat 拼接一个\t

例如这样的sql里的

concat('\t',a.ding_userid),

select
  a.id,
  a.username,
  a.nickname,
  a.phone,
  a.create_time,
  d.name as store_name,
  a.status,
  a.work_types,
  CASE
    a.work_types
    WHEN "2,4" THEN '育婴师,保姆'
    WHEN "1,2,4" THEN '母婴护理师,育婴师,保姆'
    WHEN "3,11" THEN '催乳,产康'
    WHEN "1,2" THEN '母婴护理师,育婴师'
    WHEN "1,4" THEN '母婴护理师,保姆'
    WHEN "1,2,3,4" THEN '母婴护理师,育婴师,催乳,保姆'
    ELSE e.desc
  END AS many_work,
  a.grade,
  concat('\t',a.ding_userid),
  a.organization_id,
  concat('\t',a.snow_id),
  b.name,
  c.name
from
  mumway_admin a
  left join mumway_admin_department b on a.department_pid = b.id
  left join mumway_admin_department c on a.department_id = c.id
  left join mumway_store d on a.store_id = d.id
  left join mumway_masterneed e on e.id = a.work_types
where
  a.in_status != 3
order by
  a.id desc
limit
  5000;