SQL SELECT LIKE (Insensitive casing)

user2583714 picture user2583714 · Sep 17, 2013 · Viewed 74.3k times · Source

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 ).

When I execute this query i don't get any rows. How do i make the call such that, it looks for 'value' irrespective of the casing of the characters ?

Answer

JGutierrezC picture JGutierrezC · Sep 17, 2013

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 qt
where LOWER(column_name) LIKE LOWER('%vAlUe%');