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 ).
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%');
I know this is a very old question, but I'm posting this for posterity:
Non-binary string comparisons (including LIKE
) are case-insensitive by default in MySql:
https://dev.mysql.com/doc/refman/en/case-sensitivity.html
This will eventually do the same thing. The ILIKE works, irrespective of the casing nature
SELECT * FROM table WHERE column_name ILIKE "%value%"
If you are using PostgreSQL, a simpler solution is to use insensitive like (ILIKE):
SELECT * FROM table WHERE column ILIKE '%value%'
you should use either lower or upper function to ignore the case while you are searching for some field using like.
select * from student where upper(sname) like 'S%';
OR
select * from student where lower(sname) like 'S%';
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%');