SQL LIKE

Pattern matching for text — case-sensitive by default in Postgres.

What & Why

LIKE matches text against a pattern using two wildcard characters: % (any sequence of characters, including none) and _ (exactly one character).

See How It Works

BUSINESS QUESTION

Find campaigns whose names end with 'ing'.

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
Watch like check each rowRow 1 of 4
-- checking Spring Launch: 'Spring Launch' LIKE '%ing'?FALSE — dropped
name
Spring Launch
Retention Webinar
Finance Retargeting
Enterprise Search

name LIKE '%ing' is false for Spring Launch.

EXAMPLE QUERY
SELECT name FROM marketing.campaigns
WHERE name LIKE '%ing';
Now You Try

Practice this concept

Marketing wants leads with valid-looking email values. Find lead emails that contain an at-sign.

Available schema
marketing

Prefix tables with marketing.table_name.

idemailsource
marketing.leads
ColumnType
idinteger
campaign_idinteger
emailtext
created_attimestamp with time zone
qualified_attimestamp with time zone
converted_attimestamp with time zone
lead_scoreinteger
sourcetext
countrytext
archive_statustext
query.sql
Beginner business practice

Sign up free to try it on a real business scenario