Can we match for a specific casing of text?


#1

Question

In the context of this code challenge, can we match for a specific casing of text?

Answer

Yes, this is possible.

By default, text matching using LIKE is case-insensitive, however we can utilize a special type of statement in SQLite, known as a PRAGMA statement. PRAGMA statements are a specific type of statement in SQLite, and can be used to modify certain behaviors of the available functionality.

The following is an example of how it can be applied.

/* Run this statement to allow case-sensitive
matching on the LIKE operator */
PRAGMA case_sensitive_like = true;

/* This statement will now only match text that 
contains the exact casing of "Code" */
SELECT *
FROM table
WHERE column LIKE '%Code%';