user2583714 user2583714 - 3 years ago 152
SQL Question

SQL SELECT LIKE (Insensitive casing)

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 Source

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%');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download