Bonjour,
Comment faire marcher une jointure lorsq les 2 champs sont nuls.
je travaille avec oracle 10g
Merci
Bonjour,
Comment faire marcher une jointure lorsq les 2 champs sont nuls.
je travaille avec oracle 10g
Merci
Plusieurs solutions
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 a.col ||'X' = b.col ||'X' (a.col = b.col OR (a.col IS NULL AND b.col IS NULL)) NVL(a.col, '-1') = NVL(b.col, '-1') -- avec '-1' une valeur que ne peut avoir col. J'utilise assez souvent le chr(2) pour les varchar2. NULLIF(a.col, b.col) IS NULL AND NULLIF(b.col, a.col) IS NULL
En ajoutant une condition dans le where.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 SELECT * FROM t1, t2 WHERE t1.nom = t2.nom OR (t1.nom IS NULL AND t2.nom IS NULL)
Partager