LES TABLES :
Code : Tout sélectionner
magasin;
+---------------+-----------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+-----------------+------+-----+---------+-------+
| nom_mag | char(32) | NO | | NULL | |
| matricule_mag | int(4) unsigned | NO | PRI | NULL | |
| adresse | char(75) | NO | | NULL | |
+---------------+-----------------+------+-----+---------+-------+
lieux;
+-----------------+-----------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+-----------------+------+-----+---------+-------+
| matricule_lieux | int(6) unsigned | NO | PRI | NULL | |
| matricule_mag | int(4) unsigned | NO | | NULL | |
| adresse | char(75) | NO | | NULL | |
+-----------------+-----------------+------+-----+---------+-------+
responsable;
+-------------+------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+------------------+------+-----+---------+-------+
| num_pers | int(11) unsigned | NO | PRI | NULL | |
| nom_pers | char(32) | NO | | NULL | |
| prenom_pers | char(32) | NO | | NULL | |
+-------------+------------------+------+-----+---------+-------+
represente;
+---------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------------+------+-----+---------+-------+
| num_pers | tinyint(4) unsigned | NO | PRI | NULL | |
| matricule_mag | int(4) unsigned | NO | PRI | NULL | |
| categorie | char(32) | NO | | NULL | |
+---------------+---------------------+------+-----+---------+-------+
represente2;
+-----------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+---------------------+------+-----+---------+-------+
| num_pers | tinyint(4) unsigned | NO | PRI | NULL | |
| matricule_lieux | int(6) unsigned | NO | PRI | NULL | |
| categorie | char(32) | NO | | NULL | |
+-----------------+---------------------+------+-----+---------+-------+Code : Tout sélectionner
responsable;
+----------+----------+-------------+
| num_pers | nom_pers | prenom_pers |
+----------+----------+-------------+
| 1 | Dupond | Pierre |
| 2 | Dupont | Paul |
| 3 | Faure | Jacques |
| 4 | Moreau | François |
+----------+----------+-------------+
magasin;
+-----------+---------------+---------+
| nom_mag | matricule_mag | adresse |
+-----------+---------------+---------+
| Auchan | 1 | Paris |
| Carrefour | 2 | Paris |
| Casino | 3 | Lille |
| Cora | 4 | Nantes |
+-----------+---------------+---------+
lieux;
+-----------------+---------------+----------+
| matricule_lieux | matricule_mag | adresse |
+-----------------+---------------+----------+
| 1 | 1 | Poitiers |
| 2 | 1 | Limoges |
| 3 | 2 | Nantes |
| 4 | 3 | Poitiers |
| 5 | 3 | Paris |
+-----------------+---------------+----------+
represente;
+----------+---------------+------------+
| num_pers | matricule_mag | categorie |
+----------+---------------+------------+
| 1 | 1 | Directeur |
| 3 | 2 | Commercial |
+----------+---------------+------------+
represente2;
+----------+-----------------+-----------+
| num_pers | matricule_lieux | categorie |
+----------+-----------------+-----------+
| 1 | 1 | Comptable |
| 3 | 2 | Directeur |
+----------+-----------------+-----------+Code : Tout sélectionner
mysql> SELECT DISTINCT(responsable.num_pers), nom_pers, prenom_pers, nom_mag
-> FROM responsable, represente, represente2, lieux, magasin
-> WHERE (
-> (responsable.num_pers = represente.num_pers
-> AND represente.matricule_mag = magasin.matricule_mag)
-> OR(responsable.num_pers = represente2.num_pers
-> AND represente2.matricule_lieux = lieux.matricule_lieux
-> AND lieux.matricule_mag = magasin.matricule_mag)
-> )
-> AND nom_pers LIKE 'Dupond%'
-> ORDER BY nom_pers ASC;
+----------+----------+-------------+---------+
| num_pers | nom_pers | prenom_pers | nom_mag |
+----------+----------+-------------+---------+
| 1 | Dupond | Pierre | Auchan |
+----------+----------+-------------+---------+Enjoy!