例某表aaa
id xm
1 a
2 a
3 a
select * from aaa where xm='a' 显示无结果或少记录
正常的话,应该是 
1 a
2 a
3 a但是select * from aaa where id in (1,2,3)
则显示正常
1 a
2 a
3 a
后来我把xm都改成b,
显示结果
1 b
2 b
3 b
再后来我又把xm都改回原来的a
再查询结果就正常的。
1 a
2 a
3 a
请问有人遇到过这样的事情吗???

解决方案 »

  1.   


    like也不行的,一样的结果
      

  2.   

    --> 测试数据: @tb
    declare @tb table (id varchar(12),xm varchar(12))
    insert into @tb
    select '1','a ' union all      --- a 后是tab 键
    select '2','a ' union all
    select '3',' a' union all  ---a 前是空格   
    select '4','a ' union all  ---a 后是空格
    select '5',' a'   --- a 前是tab 键select * from @tb where xm='a'
    /*
    id           xm
    ------------ ------------
    2            a ---含有特殊字符、以及前面含有空格的查不出来
    4            a              ---如 1,3,5(2 行受影响)
     */
    select * from @tb where ltrim(xm)='a'   
    /*
    id           xm
    ------------ ------------
    2            a
    3            a ---去掉前面的空格,3可以查出
    4            a              ---含特殊字符的仍然查不出来(3 行受影响)
    */
      

  3.   

    select * from aaa where rtrim(ltrim(xm))='a'
    我这样也试过的
    不知道上面的语句有没有写错
    但也是没有结果的
      

  4.   


    select * from @tb where xm like '%a%'id           xm        
    ------------ ------------    按理说like 应该能出来
    1            a
    2            a 
    3             a
    4            a 
    5             a(5 行受影响)