In a correlated sub query is it better to use EXISTS or IN?
Is it dependent on whether or not an index exists?
Here is an example:
UPDATE TABLE1 A SET A.COL1 = (SELECT B.COL2
FROM
TABLE2 B
WHERE
A.COLX = B.COLY)
WHERE EXISTS (SELECT B.COL2
FROM
TABLE2 B
WHERE
A.COLX = B.COLY);
The UPDATE WHERE is used to limit the update so that NULL is not placed attempted to be updated where there are matching records in A but not in B.
Assistance appreciated !
OLAPer
:
Is it dependent on whether or not an index exists?
Here is an example:
UPDATE TABLE1 A SET A.COL1 = (SELECT B.COL2
FROM
TABLE2 B
WHERE
A.COLX = B.COLY)
WHERE EXISTS (SELECT B.COL2
FROM
TABLE2 B
WHERE
A.COLX = B.COLY);
The UPDATE WHERE is used to limit the update so that NULL is not placed attempted to be updated where there are matching records in A but not in B.
Assistance appreciated !
OLAPer
: