使用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
成功執行且保留兩位小數
