现有数据表tab
id name num1 aaa 020JPT1087800082
num为varchar
执行
select * from `tab`
where num like '020JPT1087800082';
无法查询到数据
必须执行
select * from `tab`
where num like '020JPT1087800082%';
才可以查询到数据 这是??
大大们帮解释下!!谢谢!
id name num1 aaa 020JPT1087800082
num为varchar
执行
select * from `tab`
where num like '020JPT1087800082';
无法查询到数据
必须执行
select * from `tab`
where num like '020JPT1087800082%';
才可以查询到数据 这是??
大大们帮解释下!!谢谢!
贴结果
我将数据更新
update `tab`
set num = '020JPT1087800082'
where num like '020JPT1087800082%';
后
select * from `tab`
where num like '020JPT1087800082';
可以查询到数据
。。
mysql> select * from `t5`
-> where trim(num) like '020JPT1087800082';
+------+------+-------------------+
| id | name | num |
+------+------+-------------------+
| 1 | aaa | 020JPT1087800082 |
+------+------+-------------------+
1 row in set (0.00 sec)
update `tab` set num=trim(num)
OR
update `tab` set num=REPLACE(num,' ','')
ASCII码
你先分析下后面的那个“非法”字符到底是什么,再用replace把它给替换掉,
按照我的经验,很可能是后面多了个回车键。通常管理员如果在excel表格里面把字段复制过来粘贴的话,
就会多出一个回车来,看不到什么特别的。
如果我猜得没错,你可以这么替换,例如:
update tab set num=replace(num,chr(13),''); update tab set num=replace(num,chr(10),'');