Case sensitive RLIKE

The MySQL REGEXP/RLIKE sucks for this - you need to cast the data as BINARY for case sensitive searching:

SELECT * 
  FROM datatbl 
 WHERE CAST(strfield  AS BINARY) rlike '[a-z]*';

You'll find this raised in the comments for the REGEXP/RLIKE documentation.


Edit: I've misread OP and this is solution for the opposite case where MySQL is in SENSITIVE collation and you need to compare string in INSENSITIVE way.

MySQL 5.x

You can workaround it using LOWER() function, too.

SELECT * 
FROM datatbl 
WHERE LOWER(strfield) RLIKE '[a-z]*';

MySQL 8+

If you are running MySQL 8+, you can also use case-insensitive switch in REGEXP_LIKE() function.

SELECT * 
FROM datatbl 
WHERE REGEXP_LIKE(strfield, '[a-z]*', 'i');

Tags:

Mysql

Regex