1

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)

Racil Hilan
  • 24,690
  • 13
  • 50
  • 55
Aditya
  • 63
  • 7
  • It depends on which collation you're working on. Some collations are case-insensitive (e.g. `utf8-general-ci`), while some others are not. – Raptor Feb 21 '18 at 04:44
  • Please try this link: https://stackoverflow.com/questions/18853452/sql-select-like-insensitive-casing – Kannan K Feb 21 '18 at 04:46

2 Answers2

2

Try this:

select t1.*
from table1 t1
where LOWER(column_name) LIKE LOWER('%BEJO%');
Kannan K
  • 4,411
  • 1
  • 11
  • 25
0

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%');
Racil Hilan
  • 24,690
  • 13
  • 50
  • 55