select *
from table
where id ='4fawef'

select *
from table
where id ='4'
这两个sql怎么都把id=4的数据查询出来了? 

解决方案 »

  1.   

    show variables like 'char%'; 
    id内容是什么
      

  2.   

    你的ID是什么数字类型? desc table 贴出来看一下,如果ID是数字,则你不应该加单引号。
      

  3.   

    mysql> select * from test1  where a ='4a';
    +------+------+
    | a    | b    |
    +------+------+
    |    4 |    5 |
    +------+------+
    1 row in set, 1 warning (0.00 sec)mysql> select * from test1  where a ='4ssssssssa';
    +------+------+
    | a    | b    |
    +------+------+
    |    4 |    5 |
    +------+------+
    1 row in set, 1 warning (0.00 sec)mysql默认非严格模式  因为是id是整性  字符'4ssssssssa'自动去取前几位整数类型
      

  4.   

    mysql> select * from test1  where a ='44ssssssssa';
    Empty set, 1 warning (0.00 sec)