Files
Exercice-SQL/Exercice-SQL.sql
2025-10-14 20:02:26 +00:00

32 lines
1.0 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

--- Exercice 1
INSERT INTO Auteurs (nom, prenom)
VALUES ('Dumas', 'Alexandre');
SELECT auteur_id FROM Auteurs
WHERE nom = 'Dumas' AND prenom = 'Alexandre';
INSERT INTO Livres (titre, annee_publication, auteur_id, resume)
VALUES ('Les Trois Mousquetaires', 1844, 4, 'Roman historique daventures suivant dArtagnan et les mousquetaires du roi.');
INSERT INTO Livres (titre, annee_publication, auteur_id, resume)
VALUES ('Harry Potter et le Prisonnier dAzkaban', 1999, 3, 'Troisième aventure du jeune sorcier à Poudlard.');
--- Exercice 2
SELECT * FROM Livres WHERE annee_publication < 1900;
SELECT * FROM Auteurs WHERE prenom = 'Victor';
SELECT * FROM Livres WHERE titre LIKE '%Paris%';
--- Exercice 3
DELETE FROM Livres WHERE titre = 'Notre-Dame de Paris';
SELECT * FROM Livres WHERE titre = 'Notre-Dame de Paris';
--- Exercice 4
SELECT L.titre, A.nom FROM Livres L JOIN Auteurs A ON L.auteur_id = A.auteur_id;
SELECT L.titre, A.nom FROM Livres L JOIN Auteurs A ON L.auteur_id = A.auteur_id WHERE L.annee_publication > 1900;