我们在查询数据库时,时常需要将查询到的数据进行类型转换。
我在将int型数据转换成string型数据时,数据库报了一个错误:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use........
使用的数据库查询语句为:
select cast(id as varchar) as ID from........
使用的mysql服务器版本为:
解决方法为将varchar改为char:
select cast(id as char) as ID from........
再次查询,发现没有报错,成功运行,猜想报错的原因可能是服务器版本的问题。
版权声明:本文为m0_37461416原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。