sSQL = "select * from t_clients"


 TABLE DES CLIENTS

no	ID	Nom

-----------------------------------------------------------

1	#1	Luc

2	#2	Claude

3	#3	Pierre

4	#4	Julien

5	#5	Carl

6	#6	André

sSQL = "select * from t_prods"


 TABLE DES PRODUITS

no	ID	Nom

-----------------------------------------------------------

1	#13	table

2	#1	table

3	#2	radio

4	#3	ordinateur

5	#4	auto

6	#5	maison

7	#6	table

8	#7	ordinateur

9	#8	auto

10	#9	table

11	#10	maison

12	#11	moto

sSQL = "select * from t_couls"


 TABLE DES COULEURS

no	ID	Nom

-----------------------------------------------------------

1	#1	Bleu

2	#2	Rouge

3	#3	Vert

4	#4	Orange

5	#5	Blanc

6	#6	Noir

sSQL = "select * from t_pieces"


 TABLE DES PIECES

no	ID	Nom

-----------------------------------------------------------

1	#1	écran

2	#2	imprimante

3	#3	clavier

4	#4	souris

5	#5	garage

6	#6	Sale à manger

7	#7	Chambre

8	#8	pneu

9	#9	porte

10	#10	frein

11	#11	lumière

sSQL = "select * from t_clients INNER JOIN t_prods ON t_clients.v_client_id = t_prods.v_client_id"


 INNER JOIN SIMPLE

no	ID	Nom	Produit

-----------------------------------------------------------

1	#3	Pierre 	table

2	#1	Luc 	table

3	#2	Claude 	radio

4	#3	Pierre 	ordinateur

5	#3	Pierre 	auto

6	#4	Julien 	maison

7	#3	Pierre 	table

8	#1	Luc 	ordinateur

9	#2	Claude 	auto

10	#2	Claude 	table

11	#3	Pierre 	maison

sSQL = "select * from t_clients LEFT JOIN t_prods ON t_clients.v_client_id = t_prods.v_client_id"


 LEFT JOIN SIMPLE

no	ID	Nom	Produit

-----------------------------------------------------------

1	#1	Luc	table

2	#1	Luc 	ordinateur

3	#2	Claude 	radio

4	#2	Claude 	auto

5	#2	Claude 	table

6	#3	Pierre 	table

7	#3	Pierre 	ordinateur

8	#3	Pierre 	auto

9	#3	Pierre 	table

10	#3	Pierre 	maison

11	#4	Julien 	maison

12	#-	Carl 	-  (Erreur t_prods.v_client_id n'existe pas)

13	#-	André	-  (Erreur t_prods.v_client_id n'existe pas)

Pour ajuster, préciser de orendre le ID de la table t_clients. On devrait toujours le faire de toute façon!

sSQL = "select t_clients.v_client_id, t_clients.v_client_nom, t_prods.v_prod_nom from t_clients LEFT JOIN t_prods ON t_clients.v_client_id = t_prods.v_client_id"


 LEFT JOIN SIMPLE AJUSTÉ

no	ID	Nom	Produit

-----------------------------------------------------------

1	#1	Luc 	table

2	#1	Luc 	ordinateur

3	#2	Claude 	radio

4	#2	Claude 	auto

5	#2	Claude 	table

6	#3	Pierre 	table

7	#3	Pierre 	ordinateur

8	#3	Pierre 	auto

9	#3	Pierre 	table

10	#3	Pierre 	maison

11	#4	Julien 	maison

12	#5	Carl	-

13	#6	André 	-

sSQL = "select * from t_clients RIGHT JOIN t_prods ON t_clients.v_client_id = t_prods.v_client_id"
ou sSQL = "select * from t_clients t1 RIGHT JOIN t_prods t2 ON t1.v_client_id = t2.v_client_id"


 RIGHT JOIN SIMPLE

no	ID	Nom	Produit

-----------------------------------------------------------

1	#3	Pierre 	table

2	#1	Luc 	table

3	#2	Claude 	radio

4	#3	Pierre 	ordinateur

5	#3	Pierre 	auto

6	#4	Julien 	maison

7	#3	Pierre 	table

8	#1	Luc 	ordinateur

9	#2	Claude 	auto

10	#2	Claude 	table

11	#3	Pierre 	maison

12	#0	- 	moto

sSQL = "select t1.v_client_id, t1.v_client_nom, t2.v_prod_nom, t3.v_coul_nom from (t_clients t1 INNER JOIN t_prods t2 ON t1.v_client_id = t2.v_client_id) LEFT JOIN t_couls t3 ON t2.v_coul_id = t3.v_coul_id"


 RELATIONS 3 TABLES

no	ID	Nom	Produit		Couleur

-----------------------------------------------------------

1	#3	Pierre 	table		Bleu

2	#1	Luc 	table 		Bleu

3	#2	Claude 	radio 		Bleu

4	#3	Pierre 	ordinateur	Rouge

5	#3	Pierre 	auto 		Rouge

6	#4	Julien 	maison 		Vert

7	#3	Pierre 	table		Rouge

8	#1	Luc 	ordinateur 	Vert

9	#2	Claude 	auto 		Bleu

10	#2	Claude 	table 		Vert

11	#3	Pierre 	maison 		Rouge

sSQL = "select t1.v_client_id, t1.v_client_nom, t2.v_prod_nom, t3.v_coul_nom from (t_clients t1 INNER JOIN t_prods t2 ON t1.v_client_id = t2.v_client_id) INNER JOIN t_couls t3 ON t2.v_coul_id = t3.v_coul_id ORDER by t1.v_client_nom, t2.v_prod_nom"


 RELATIONS 3 TABLES MIEUX (liste de tous les produits vendus , avec son client et sa couleur. 

no	ID	Nom	Produit		Couleur

-----------------------------------------------------------

1	#2	Claude 	auto 		Bleu

2	#2	Claude 	radio 		Bleu

3	#2	Claude 	table 		Vert

4	#4	Julien 	maison 		Vert

5	#1	Luc 	ordinateur 	Vert

6	#1	Luc 	table 		Bleu

7	#3	Pierre 	auto 		Rouge

8	#3	Pierre 	maison 		Rouge

9	#3	Pierre 	ordinateur 	Rouge

10	#3	Pierre 	table 		Rouge

11	#3	Pierre 	table 		Bleu

sSQL = "select t1.v_client_id, t1.v_client_nom, t2.v_prod_nom, t3.v_coul_nom, t4.v_piece_nom from ((t_clients t1 INNER JOIN t_prods t2 ON t1.v_client_id = t2.v_client_id) LEFT JOIN t_couls t3 ON t2.v_coul_id = t3.v_coul_id) INNER JOIN t_pieces t4 ON t2.v_prod_id = t4.v_prod_id"


 RELATIONS 4 TABLES

 no	ID	Nom	Produit		Couleur	Pièce

-----------------------------------------------------------

1	#3	Pierre 	ordinateur 	Rouge 	écran

2	#3	Pierre 	ordinateur 	Rouge 	imprimante

3	#3	Pierre 	ordinateur 	Rouge 	clavier

4	#3	Pierre 	ordinateur 	Rouge 	souris

5	#4	Julien 	maison 		Vert 	garage

6	#4	Julien 	maison 		Vert 	Sale à manger

7	#4	Julien 	maison 		Vert 	Chambre

8	#3	Pierre 	auto 		Rouge 	pneu

9	#3	Pierre 	auto 		Rouge 	porte

10	#3	Pierre 	auto 		Rouge 	frein

11	#3	Pierre 	auto 		Rouge 	lumière