SQL Pattern Matching And Collation

Guides correct, portable text matching in SQL — LIKE with its `%` (any sequence) and `_` (any single character) wildcards, the ESCAPE clause for literal `%`/`_`, and the central trap that LIKE's case sensitivity is decided by the active COLLATION and therefore silently differs across engines (case-SENSITIVE in standard SQL and PostgreSQL, case-INSENSITIVE under the common MySQL/SQL Server default collations, case-insensitive for ASCII only in SQLite) so the identical query returns different. Auto-invokes when writing or editing a LIKE/ILIKE/SIMILAR TO/REGEXP/`~`/GLOB predicate, a COLLATE clause, case-insensitive or accent-insensitive search, or on "case-insensitive search", "find regardless of accents", "LIKE doesn't match" / "matched different rows on MySQL vs Postgres" requests.

ctoth 90d8aaf 3 files · 26.2 KB Updated

File contents

ctoth/sql-skills-plugin/tree/main/plugins/sql/skills/sql-pattern-matching-and-collation commit 90d8aafa7f

Frequently asked questions

npx skillmds@latest add ctoth/sql-pattern-matching-and-collation