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

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐