2024-BD-BUT1-Sen/Code/CorrectionsTP/TP3.sql

50 lines
1.3 KiB
MySQL
Raw Normal View History

2024-11-14 10:01:58 +01:00
-- Q1
select B.numbuveur, nom, ville
from buveur B, Commande C
where B.numbuveur = C.numbuveur;
select distinct B.numbuveur, nom, ville
from buveur B, Commande C
where B.numbuveur = C.numbuveur;
select distinct numbuveur, nom, ville
from buveur natural join Commande ;
select distinct numbuveur, nom, ville
from buveur join Commande using(numbuveur) ;
select distinct b.numbuveur, nom, ville
from buveur b join Commande c on (b.numbuveur=c.numbuveur);
-- Q2
select distinct numvitic, nom, prenom
from viticulteur natural join vin
where region = 'LOIRE' and millesime = 1983;
-- Q3
select distinct B.numbuveur, nom
from buveur b, commande c, vin v
where b.numbuveur = c.numbuveur and c.numvin=v.numvin and cru = 'POMMARD' ;
select distinct numbuveur, nom
from buveur natural join commande natural join vin
where cru = 'POMMARD';
-- Q4
select distinct nom
from vin v, commande c, viticulteur t
where c.numvin = v.numvin and v.numvitic = t.numvitic and numbuveur = 1600;
select distinct nom
from commande natural join vin natural join viticulteur
where numbuveur = 1600;
select distinct nom
from viticulteur
where numvitic in (select numvitic
from vin
where numvin in (select numvin
from commande
where numbuveur = 1600));