SQL Intermediário com IA
Jasmin Ludolf
Senior Data Science Content Developer


$$
*: seleciona tudo$$
Dois curingas de correspondência de padrões:
%_
Prompt: Mostrar títulos de filmes que contêm 'love'
SELECT title
FROM films
WHERE title LIKE '%love%';
|title |
|------------------------|
|Dr. Strangelove or: H...|
|Beloved |
|Cloverfield |
|The Oogieloves in the...|
...
$$
%:
%love%:Prompt: Mostrar títulos de filmes que contêm 'love' em qualquer caso
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: Mostrar títulos de filmes que terminam com 'and', qualquer caso
SELECT title
FROM films
WHERE LOWER(title) LIKE '%and';
|title |
|------------------------|
|Alexander's Ragtime Band|
|Wonderland |
|Finding Neverland |
...
Prompt: Mostrar títulos de filmes que começam com 'and', qualquer caso
SELECT title
FROM films
WHERE LOWER(title) LIKE 'and%';
|title |
|------------------|
|And Then Came Love|
|Anderson's Cross |
|And So It Goes |
Prompt: Mostrar títulos de filmes com cinco letras começando com E
SELECT title
FROM films
WHERE title LIKE 'E____';
|title|
|-----|
|Evita|
|Earth|
Prompt: Mostrar títulos de filmes que não começam com 'The'
SELECT title
FROM films
WHERE title NOT LIKE 'The%';
|title |
|--------------------|
|Intolerance: Love...|
|Over the Hill to ...|
|Metropolis |
...


$$
$$
$$
*: seleciona todos os campos_: correspondência de caracteres%: posição
LIKE: correspondência de padrõesNOT LIKE: exclui padrõesILIKE: insensível a maiúsculasUPPER() / LOWER(): padroniza capitalizaçãoSQL Intermediário com IA