Interroger SQL de façon intermédiaire avec l'IA
Jasmin Ludolf
Senior Data Science Content Developer


$$
* : sélectionner tout$$
Deux caractères génériques pour les motifs :
%_
Consigne : Afficher les titres de films contenant « love »
SELECT title
FROM films
WHERE title LIKE '%love%';
|title |
|------------------------|
|Dr. Strangelove or: H...|
|Beloved |
|Cloverfield |
|The Oogieloves in the...|
...
$$
% :
%love% :Consigne : Afficher les titres contenant « love », peu importe la casse
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 »Consigne : Afficher les titres se terminant par « and », peu importe la casse
SELECT title
FROM films
WHERE LOWER(title) LIKE '%and';
|title |
|------------------------|
|Alexander's Ragtime Band|
|Wonderland |
|Finding Neverland |
...
Consigne : Afficher les titres commençant par « and », peu importe la casse
SELECT title
FROM films
WHERE LOWER(title) LIKE 'and%';
|title |
|------------------|
|And Then Came Love|
|Anderson's Cross |
|And So It Goes |
Consigne : Afficher les titres de cinq lettres commençant par E
SELECT title
FROM films
WHERE title LIKE 'E____';
|title|
|-----|
|Evita|
|Earth|
Consigne : Afficher les titres dont le titre ne commence pas par « The »
SELECT title
FROM films
WHERE title NOT LIKE 'The%';
|title |
|--------------------|
|Intolerance: Love...|
|Over the Hill to ...|
|Metropolis |
...


$$
$$
$$
* : sélectionne tous les champs_ : correspondance de caractère% : position
LIKE : appariement de motifsNOT LIKE : exclut des motifsILIKE : insensible à la casseUPPER() / LOWER() : uniformiser la casseInterroger SQL de façon intermédiaire avec l'IA