Jointure : question de syntaxe ou performance
Bonjour,
Table MA_TABLE (A, Bfk, C, D)
où Bfk est une colonne que l'on peut jondre la table Tb (FK)
Code:
1 2 3
| select t.* from MA_TABLE t
join Tb on Tb.Bfk = t.Bfk
where Tb.filtre1 = 2 and Tb.filtre2 = 'V' |
est-il différent de
Code:
1 2
| select t.* from MA_TABLE t
join Tb on (Tb.Bfk = t.Bfk and Tb.filtre1 = 2 and Tb.filtre2 = 'V') |
En fait j'essaie aussi d'optimiser cette requête (longue!)
Code:
1 2 3 4 5 6 7 8
| select *
from t1
join t2_v1 on t2_v1.a = t1.a
join t2_v2 on t2_v2.a = t1.a
left join t3_v1 on (t3_v1.b = t2_v1.b and t3_v1.filtre1 = 1 and Tb.filtre2 = 'V')
left join t3_v2 on (t3_v2.b = t2_v2.b and t3_v2.filtre1 = 2 and Tb.filtre2 = 'V')
...
where... |
mais on ne peut pas faire 2 outer join sur la même table donc ça, ça ne marche pas :
Code:
1 2 3 4 5 6 7
| select *
from t1
join t2 on t2.a = t1.a
left join t3_v1 on (t3_v1.b = t2.b and t3_v1.filtre1 = 1 and Tb.filtre2 = 'V')
left join t3_v2 on (t3_v2.b = t2.b and t3_v2.filtre1 = 2 and Tb.filtre2 = 'V')
...
where... |