Blueherb In solitude, where we are least alone 王佳鑫

mysql 字段名为 timestamp ,不让转义

select ip_type 'IP类型', timestamp '数据填报时间' from ( select d.id, if(d.ip_type = 0, 'IP', 'IP段') ip_type , d.timestamp, (CASE d.visible WHEN 0 THEN '否' WHEN 1 THEN '是' ELSE '' END)visible from aaa_tab d where timestamp <= '2022-04-30 23:59:59') t1 order by id desc

提示 SQL 错误 [1525] [HY000]: Incorrect DATETIME value: '数据填报时间'

修改为:t1.timestamp ,给 timestamp 加引号
select ip_type 'IP类型', t1.timestamp '数据填报时间' from ( select d.id, if(d.ip_type = 0, 'IP', 'IP段') ip_type , d.timestamp, (CASE d.visible WHEN 0 THEN '否' WHEN 1 THEN '是' ELSE '' END)visible from aaaa_tab d where timestamp <= '2022-04-30 23:59:59') t1 order by id desc

posted @ 2022-12-22 10:36  阿呆学习之路  阅读(166)  评论(0编辑  收藏  举报