SQL ILIKE

Postgres's case-insensitive version of LIKE — same wildcards, no case sensitivity.

What & Why

ILIKE is a Postgres-specific extension that works exactly like LIKE, except it ignores letter case entirely.

See How It Works

BUSINESS QUESTION

Match the campaign name 'Spring Launch' even when the search text uses uppercase letters.

idnamechannelspendstart_dateend_datestatustarget_segment
1Spring Launchgoogle_ads55000.002024-01-152024-03-31activesmb
2Retention Webinaremail45000.002024-02-102024-04-15activeenterprise
3Finance Retargetinglinkedin50000.002024-03-122024-05-31activeenterprise
4Enterprise Searchgoogle_ads60000.002024-04-012024-06-30activeenterprise
EXAMPLE QUERY
-- plain LIKE is case-sensitive and does not match
SELECT name FROM marketing.campaigns WHERE name LIKE 'SPRING LAUNCH';

-- ILIKE ignores letter case and matches the row
SELECT name FROM marketing.campaigns WHERE name ILIKE 'SPRING LAUNCH';
RESULT — ILIKE version
name
Spring Launch

ILIKE matches the stored mixed-case campaign name.

Now You Try

Practice this concept

Product wants features whose name or description mentions SQL, regardless of capitalization.

Available schema
product

Prefix tables with product.table_name.

namedescriptionteam
product.features
ColumnType
idinteger
nametext
descriptiontext
teamtext
released_attimestamp with time zone
deprecated_attimestamp with time zone
internal_priorityinteger
query.sql
Beginner business practice

Sign up free to try it on a real business scenario