Salut,

J'aimerais effectuer un update sur un champ d'une table à partir d'une deuxième table mais ma jointure est sur 3 champs

Voici ma syntaxe qui fonctionne

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
UPDATE TABLE1 t1 
 SET champ1table1 = ( 
 SELECT champtable2 
 FROM TABLE2 t2 
 WHERE t2.c1=  t1.c1 
 and t2.c2 =  t1.c2 
 and t2.c3 =  t1.c3 
  ) 
  where c4 = 'condition1' 
AND c5 = 'condition2'
J'aimerias savoir s'il y a un moyen d'optimiser cette requête par exemple en rajoutant les condition du where à la fin de ma requete mais cela ne fonctionne pas

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
UPDATE TABLE1 t1 
 SET champ1table1 = ( 
 SELECT champtable2 
 FROM TABLE2 t2 
 WHERE t2.c1=  t1.c1 
 and t2.c2 =  t1.c2 
 and t2.c3 =  t1.c3 
  ) 
  where c4 = 'condition1' 
AND c5 = 'condition2'
and t2.c1=  t1.c1 
 and t2.c2 =  t1.c2 
 and t2.c3 =  t1.c3
merci pour votre aide