Intermediate SQL with AI
Jasmin Ludolf
Senior Data Science Content Developer
$$
*
: select all$$
Two pattern matching wildcards:
%
_
Prompt: Show film titles containing 'love'
SELECT title
FROM films
WHERE title LIKE '%love%';
|title |
|------------------------|
|Dr. Strangelove or: H...|
|Beloved |
|Cloverfield |
|The Oogieloves in the...|
...
$$
%:
%love%
:Prompt: Show film titles containing 'love' in any case
SELECT title
FROM films
WHERE title ILIKE '%love%';
|title |
|---------------------|
|Intolerance: Love'...|
|Love Me Tender |
|From Russia with Love|
...
SELECT title
FROM films
WHERE LOWER(title) LIKE '%love%';
$$
LOWER(title)
: "love actually"SELECT title
FROM films
WHERE UPPER(title) LIKE '%LOVE%';
$$
UPPER(title)
: "LOVE ACTUALLY"Prompt: Show film titles ending with 'and', any case
SELECT title
FROM films
WHERE LOWER(title) LIKE '%and';
|title |
|------------------------|
|Alexander's Ragtime Band|
|Wonderland |
|Finding Neverland |
...
Prompt: Show film titles starting with 'and', any case
SELECT title
FROM films
WHERE LOWER(title) LIKE 'and%';
|title |
|------------------|
|And Then Came Love|
|Anderson's Cross |
|And So It Goes |
Prompt: Show five-letter film titles starting with E
SELECT title
FROM films
WHERE title LIKE 'E____';
|title|
|-----|
|Evita|
|Earth|
Prompt: Show film titles whose titles don't start with 'The'
SELECT title
FROM films
WHERE title NOT LIKE 'The%';
|title |
|--------------------|
|Intolerance: Love...|
|Over the Hill to ...|
|Metropolis |
...
$$
$$
$$
*
: selects all fields_
: character matching%
: positionLIKE
: pattern matchingNOT LIKE
: excludes patternsILIKE
: case-insensitiveUPPER()
/ LOWER()
: standardize capitalizationIntermediate SQL with AI