我们数据库明明存储的是 客户名称, 但是代码取出来,json打印一下,变成了 <U+200C>客户名称
则说明存在了0宽字符,不影响 select ... where xxx=x,的使用。
如何确认?
转化成16进制,它就能显形,查 HEX 前缀确认是不是 E2808C(U+200C 的 UTF-8 编码),再结合其它辅助字段如 gmt_create / creator_id 就能锁定是谁、什么时候建的。
sql
SELECT id, customer_code, HEX(LEFT(customer_name, 6)), creator_id, gmt_create
FROM customer_info
WHERE id = 123456);
如何修复?
转化成16进制,将其replace成空
sql
UPDATE customer_info
SET customer_name = REPLACE(customer_name, UNHEX('E2808C'), '')
WHERE customer_name LIKE CONCAT(UNHEX('E2808C'), '%');