mysql字符串中出现\r\n导致转换异常

1、针对上述问题字段在mysql数据库中进行查询,如下语句

       select * from tablesA where cola like CONCAT('%',char(10),'%');

       即可查询test表中info字段中包含换行符的数据有哪些;

2、将包含的换行符去除,执行以下语句即可

       
       update tablesA

       set cola = replace(replace(cola,char(10),''),char(13),'')

       where cola like concat('%',char(10),'%');

3、除了针对换行符\r\n外,针对\t tab制表位,可采用以下语句

      select * from tablesA where cola like CONCAT('%\t%');

       update tablesA

       set cola = replace(cola,'\t','')

       where cola like concat('%',char(10),'%');
 

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐