Search notes:

SQLite: like

Case in-sensitiveness

By default, a query involving a like does not take into effect the case of the strings compared. This cannot even be changed with the collate expression.
In order to force case sensitiveness in queries with a like expression, the pragma case_sensitive_like must be turned on:
create table tab (
  col  text
);

insert into tab values ('abc def ghi.');
insert into tab values ('Abc Def Ghi.');
insert into tab values ('ABC DEF GHI.');

select * from tab where col like '%Def%';
-- 
-- abc def ghi.
-- Abc Def Ghi.
-- ABC DEF GHI.

select * from tab where col like '%Def%' collate binary;
--
-- abc def ghi.
-- Abc Def Ghi.
-- ABC DEF GHI.

select * from tab where col collate  binary like '%Def%' collate binary;
--
-- abc def ghi.
-- Abc Def Ghi.
-- ABC DEF GHI.


pragma case_sensitive_like = true;

select * from tab where col like '%Def%';
--
-- Abc Def Ghi.
Github repository about-sqlite, path: /sql/expressions/like/case-sensitiveness.sql

See also

The glob operator.
expressions

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758207103, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/databases/SQLite/sql/expressions/like/index(81): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78