SQL SELECT LIKE (Insensitive casing) SQL SELECT LIKE (Insensitive casing) mysql mysql

SQL SELECT LIKE (Insensitive casing)


use LOWER Function in both (column and search word(s)). Doing it so, you assure that the even if in the query is something like %VaLuE%, it wont matter

select qt.*from query_table qtwhere LOWER(column_name) LIKE LOWER('%vAlUe%');


Either use a case-insensitive collation on your table, or force the values to be lower case, e.g.

WHERE lower(column) LIKE lower('%value%');


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.