现有数据表tab
id     name        num1      aaa     020JPT1087800082
num为varchar
执行
select * from `tab`
where num like '020JPT1087800082';
无法查询到数据
必须执行
select * from `tab`
where num like '020JPT1087800082%';
才可以查询到数据  这是??
  大大们帮解释下!!谢谢!

解决方案 »

  1.   

    show create table tbname
    贴结果
      

  2.   

    补充下。
    我将数据更新
    update `tab`
    set num = '020JPT1087800082'
    where num like '020JPT1087800082%';

    select * from `tab`
    where num like '020JPT1087800082';
    可以查询到数据
    。。
      

  3.   


    mysql> select * from `t5`
        -> where trim(num) like '020JPT1087800082';
    +------+------+-------------------+
    | id   | name | num               |
    +------+------+-------------------+
    |    1 | aaa  | 020JPT1087800082  |
    +------+------+-------------------+
    1 row in set (0.00 sec)
      

  4.   

    select len(num),num from  `tab`检查一下看看,估计有什么不可见字符。
      

  5.   

    SELECT LENGTH(num),CHAR_LENGTH(NUM) FROM TT
      

  6.   

    update   `tab` set num=trim(num)
      

  7.   

    用TRIM OR REPLACE
    update `tab` set num=trim(num)
    OR
    update `tab` set num=REPLACE(num,' ','')
      

  8.   

    REPLACE(num,' ','')这个不行,会把字符中的空休也替换掉。 只能用TRIM,或者 TRIM(TRAILING num)当前前提是你多出来的是空格,如果是非可见字符的话,则需要另外处理。
      

  9.   

    用SP OR 程序,将字段内容逐一取出,用ASCII得到ASCII码,查找
    ASCII码
      

  10.   


    你先分析下后面的那个“非法”字符到底是什么,再用replace把它给替换掉,
    按照我的经验,很可能是后面多了个回车键。通常管理员如果在excel表格里面把字段复制过来粘贴的话,
    就会多出一个回车来,看不到什么特别的。
    如果我猜得没错,你可以这么替换,例如:
    update tab set num=replace(num,chr(13),''); update tab set num=replace(num,chr(10),''); 
      

  11.   

    select hex(num),num,lenght(num) from ..贴出来看一下,多贴两条记录。