select t.totalprice*(select cast(s.value as decimal(3,2)) from sys_param s where s.name='积分') as info from trade_info t
在做查询乘法运算的时候,碰到了varchar跟int相乘变成字符串拼接的问题,
通过cast(value as type),将varchar转为decimal解决了此问题
本文介绍了一种在SQL查询中解决varchar与int类型相乘导致字符串拼接问题的方法,通过使用cast函数将varchar类型转换为decimal类型来实现正确运算。
select t.totalprice*(select cast(s.value as decimal(3,2)) from sys_param s where s.name='积分') as info from trade_info t
在做查询乘法运算的时候,碰到了varchar跟int相乘变成字符串拼接的问题,
通过cast(value as type),将varchar转为decimal解决了此问题

被折叠的 条评论
为什么被折叠?