SQL SELECT LIKE (Insensitive casing)

后端 未结 9 1924
野性不改
野性不改 2021-02-02 05:32

I am trying to execute the sql query:

select * from table where column like \'%value%\';

But the data is saved as \'Value\' ( V is capital ).

9条回答
  •  暖寄归人
    2021-02-02 06:29

    If you want this column be case insensitive :

    ALTER TABLE `schema`.`table` 
    CHANGE COLUMN `column` `column` TEXT CHARACTER SET 'utf8' COLLATE 'utf8_general_ci';
    

    Thus, you don't have to change your query.

    And the MySQL engine will process your query quicker than using lower() function or any other tricks.

    And I'm not sure that using lower function will be a good solution for index searching performance.

提交回复
热议问题