MySQL regex query case insensitive

后端 未结 4 834
天涯浪人
天涯浪人 2021-02-14 16:25

In my table I have firstname and last name. Few names are upper case ( ABRAHAM ), few names are lower case (abraham), few names are character starting with ucword (Abraham).

4条回答
  •  攒了一身酷
    2021-02-14 17:11

    You don't need regexp to search for names starting with a specific string or character.

    SELECT * FROM `test_tbl` WHERE cus_name LIKE 'abc%' ; 
    

    % is wildcard char. The search is case insensitive unless you set the binary attribute for column cus_name or you use the binary operator

    SELECT * FROM `test_tbl` WHERE BINARY cus_name LIKE 'abc%' ; 
    

提交回复
热议问题