发现mysql不支持大小写
这条语句发现的问题select binary a from user where a like binary '%A%'
发现他得到的结果很多字段值是没有A的 
只有小写的a 这个问题如何解决  难道一定要用regexp??(如何用这个语句如何写)

解决方案 »

  1.   

    mysql> show full columns from t1;
    +-------+-------------+-------------------+-------------------------------+---------+
    | Field | Type        | Collation         | Nulleges                      | Comment |
    +-------+-------------+-------------------+-------------------------------+---------+
    | id    | int(11)     | NULL              | NOt,insert,update,references |         |
    | col   | varchar(30) | latin1_swedish_ci | YESt,insert,update,references |         |
    +-------+-------------+-------------------+-------------------------------+---------+
    2 rows in set (0.02 sec)mysql> select * from t1 where col regexp 'A';
    +----+--------+
    | id | col    |
    +----+--------+
    |  1 | aaaaaa |
    |  2 | AAAAAA |
    +----+--------+
    2 rows in set (0.06 sec)mysql> alter table t1 modify col varchar(30)  CHARACTER SET latin1 COLLATE latin
    1_general_cs;
    Query OK, 3 rows affected (0.14 sec)
    Records: 3  Duplicates: 0  Warnings: 0mysql> show full columns from t1;
    +-------+-------------+-------------------+------+-----+---------+-------+------
    | Field | Type        | Collation         | Null | Key | Default | Extra | Privi
    +-------+-------------+-------------------+------+-----+---------+-------+------
    | id    | int(11)     | NULL              | NO   | PRI | NULL    |       | selec
    | col   | varchar(30) | latin1_general_cs | YES  |     | NULL    |       | selec
    +-------+-------------+-------------------+------+-----+---------+-------+------
    2 rows in set (0.02 sec)mysql> select * from t1 where col regexp 'A';
    +----+--------+
    | id | col    |
    +----+--------+
    |  2 | AAAAAA |
    +----+--------+
    1 row in set (0.00 sec)mysql>
      

  2.   

     select * from t1 where col = 'A';
     select * from t1 where binary col = 'A'; select * from t1 where col regexp 'A';
     select * from t1 where col regexp binary'A';
    总共4种情况 
      

  3.   

    检查你表上的字符校对集的设置。  show full columns from t1;
      

  4.   

    show full columns from t1;都是utf8_general_ci
      

  5.   

    | ip                            | varchar(16)      | utf8_general_ci | YES  |     | NULL    |                | select,insert,update,references 这个没有用的    公司统一的不能随意动的额