当MySQL将varchar 使用cast转换成float的时候报错处理

使用MySQL将varchar转换成float是报错
执行语句:

SELECT CAST(2000 AS FLOAT) as result

错误信息:

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FLOAT) as result' at line 1

处理方式:

SELECT cast('2022' as DECIMAL(10,2)) as result

成功执行且保留两位小数

posted @ 2022-03-17 15:36  Incercadi  阅读(871)  评论(0编辑  收藏  举报