Aditya
Aditya

Reputation: 63

How I get data in using LIKE without differentiating between uppercase And lowercase?

I'm trying to get names using Like '%BEJO%', but no record is found because my data in database is 'Bejo'.

How I do I get the name 'Bejo' with LIKE '%BEJO%'? (case insensitive)

Upvotes: 1

Views: 1023

Answers (3)

Bobby Mbogo
Bobby Mbogo

Reputation: 11

JUST use the ILIKE KEYWORD that will handle all cases exmaple

SELECT * FROM film WHERE title ILIKE 'c%' LIMIT 10

Upvotes: 0

Racil Hilan
Racil Hilan

Reputation: 25351

It seems the collation of that column is case-sensitive. If you want it to always be case-insensitive, then change its collation to the one that ends with ci. If you want to keep it the way it is and only make the query case-insensitive, then you can change the collation in the query. Example:

SELECT *
FROM table1
WHERE name LIKE '%BEJO%' COLLATE utf8_general_ci;

Alternatively, you can simply change the case of both sides using LOWER() or UPPER(). Example:

SELECT *
FROM table1
WHERE UPPER(name) LIKE UPPER('%BEJO%');

Upvotes: 0

Kannan K
Kannan K

Reputation: 4461

Try this:

select t1.*
from table1 t1
where LOWER(column_name) LIKE LOWER('%BEJO%');

Upvotes: 2

Related Questions