Requête "au moins" SQL

Fermé
Étienne9 Messages postés 1022 Date d'inscription mardi 1 mars 2011 Statut Membre Dernière intervention 10 mai 2015 - 9 déc. 2012 à 13:24
jee pee Messages postés 39577 Date d'inscription mercredi 2 mai 2007 Statut Modérateur Dernière intervention 16 avril 2024 - 16 déc. 2012 à 13:20
Bonjour à tous,

Mes tables sont ci-dessous et j'aimerai faire cette requête, pouvez-vous m'aider s'il vous plaît ?

Question que j'essaie de faire :
-- Quels sont les paysagistes qui se sont au moins occupés des clients 4 et 10.

Merci beaucoup d'avance !

CREATE TABLE JARDINIER
(
NumJa integer,
NomJa char(60),
PrenomJa char(70),
MailJa char(150),
TelJa integer,
Specialite char(70),
AdresseJa char(100),
PRIMARY KEY(NumJa)
);
CREATE TABLE EQUIPE
(
NumEq integer,
NomEq char(40),
NumJa integer,
PRIMARY KEY(NumEq),
FOREIGN KEY(NumJa) REFERENCES JARDINIER --Pour numéro de chef qui est un jardinier.
);
CREATE TABLE CLIENT
(
NumCl integer,
NomCl char(50),
PrenomCl char(50),
AdresseCl char(200),
TelCl integer,
MailCl char(150),
TypeCl char(30), --Particulier, Société, municipalité
Surface integer, --En mètres carrés.
Entreprise char(30),
PRIMARY KEY(NumCl)
);
CREATE TABLE PAYSAGISTE
(
NumPa integer,
NomPa char(60),
PrenomPa char(70),
AdressePa char(100),
MailPa char(150),
TelPa integer ,
PRIMARY KEY(NumPa)
);
CREATE TABLE PROJET
(
NumPr integer,
NomPr char(50),
Date_Creation Date,
NumCl integer,
NumPa integer,
PRIMARY KEY(NumPr),
FOREIGN KEY(NumCl) REFERENCES CLIENT,
FOREIGN KEY(NumPa) REFERENCES PAYSAGISTE
);
CREATE TABLE FORFAIT
(
NumFo integer,
TypeFo char(50), --Mensuel, annuel.
Etat char(50),
PRIMARY KEY(NumFo)
);
CREATE TABLE FACTURE
(
NumFa integer,
DateFa date,
TypeFa char(50), --Forfaitaire ou à l'acte.
Detail char(50),
Montant integer, --En centimes
Adresse_Intervention char(50),
NumFo integer,
PRIMARY KEY(NumFa),
FOREIGN KEY(NumFo) REFERENCES FORFAIT
);
CREATE TABLE TACHE
(
NumTa integer,
TypeTa char(300),
Date_Heure_Intervention timestamp,
Duree_Intervention integer, -- En minutes
Jour_Intervention char(20),
NumEq integer,
NumFa integer,
NumCl integer,
NumPr integer,
NumFo integer,
PRIMARY KEY(NumTa),
FOREIGN KEY(NumEq) REFERENCES EQUIPE,
FOREIGN KEY(NumFa) REFERENCES FACTURE,
FOREIGN KEY(NumCl) REFERENCES CLIENT,
FOREIGN KEY(NumPr) REFERENCES PROJET,
FOREIGN KEY(NumFo) REFERENCES FORFAIT
);
CREATE TABLE MATERIEL
(
NumMa integer,
NomMa char(50),
Date_achat date, --connaître les anciens matériels pour changer avec des nouvelles.
NumJa integer,
PRIMARY KEY(NumMa),
FOREIGN KEY(NumJa) REFERENCES JARDINIER
);
CREATE TABLE RESERVATION
(
NumMa integer,
NumTa integer,
Date_Pret date,
Date_Retour date,
PRIMARY KEY(NumMa,NumTa,Date_Pret),
FOREIGN KEY(NumMa) REFERENCES MATERIEL,
FOREIGN KEY(NumTa) REFERENCES TACHE
);
CREATE TABLE COMPOSER
(
NumEq integer,
NumJa integer,
FOREIGN KEY(NumEq) REFERENCES EQUIPE,
FOREIGN KEY(Numja) REFERENCES JARDINIER
);



10 réponses

jee pee Messages postés 39577 Date d'inscription mercredi 2 mai 2007 Statut Modérateur Dernière intervention 16 avril 2024 9 220
9 déc. 2012 à 14:11
Salut,

select numpa from projet
where numcl = 10
and numpa in (select numpa from projet
              where numcl = 4)
/

cdlt
1