当把某个数据类型为text的字段作为查询条件时,会报错:
例1:
use Teachers
delete from 教师表 where Address='北海'
数据类型 text 和 varchar 在 equal to 运算符中不兼容。
解决办法:转换类型。
use Teachers
delete from 教师表 where cast(Address as varchar)='北海'
本文介绍了一种常见错误——当使用Text类型的字段作为查询条件时出现的数据类型不兼容问题,并提供了解决方案:通过类型转换来避免此错误。
当把某个数据类型为text的字段作为查询条件时,会报错:
例1:
use Teachers
delete from 教师表 where Address='北海'
数据类型 text 和 varchar 在 equal to 运算符中不兼容。
use Teachers
delete from 教师表 where cast(Address as varchar)='北海'
1575
1372
3820

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