Like Case Sensitive in MySQL

后端 未结 8 2397
离开以前
离开以前 2020-11-29 06:38

I have a MySQL query:

SELECT concat_ws(title,description) as concatenated HAVING concatenated LIKE \'%SearchTerm%\';

And my table is encode

8条回答
  •  一整个雨季
    2020-11-29 06:49

    Check CHARSET mentioned in the table schema:

    show create table xyz;
    

    Based on CHARSET, you can try the following.

    select name from xyz where name like '%Man%' COLLATE latin1_bin;
    select name from xyz where name like '%Man%' COLLATE utf8_bin;
    

    Following are the cases which worked for me, CHARSET=latin1, MySQL version = 5.6.

    mysql> select installsrc from appuser where installsrc IS NOT NULL and installsrc like 'Promo%' collate latin1_bin limit 1;
    +-----------------------+
    | installsrc            |
    +-----------------------+
    | PromoBalance_SMS,null |
    +-----------------------+
    1 row in set (0.01 sec)
    
    mysql>
    mysql> select installsrc from appuser where installsrc IS NOT NULL and installsrc like 'PROMO%' collate latin1_bin limit 1;
    +---------------------------+
    | installsrc                |
    +---------------------------+
    | PROMO_SMS_MISSEDCALL,null |
    +---------------------------+
    1 row in set (0.00 sec)
    
    mysql> select installsrc from appuser where installsrc IS NOT NULL and installsrc like 'PROMO%' limit 1;
    +-----------------------+
    | installsrc            |
    +-----------------------+
    | PromoBalance_SMS,null |
    +-----------------------+
    1 row in set (0.01 sec)
    

提交回复
热议问题