Subject | UPDATE sql with join like search |
---|---|
Author | Virgo Pärna |
Post date | 2013-02-25T12:32:14Z |
I'm currently trying to create update sql for something like
UPDATE TABLE1 T
SET T.VALUE1 = NULL
WHERE
T.VALUE1 IN (SELECT A.VALUE1 FROM TABLE2 A WHERE VALUE2 = ?)
But I'd like to do it so, that it uses indexes, like
SELECT T.*
FROM TABLE1 T JOIN TABLE2 A ON T.VALUE1 = A.VALUE1
WHERE A.VALUE2 = ?
There are indexes on T.VALUE1 and A.VALUE2, so the plan is something like
PLAN JOIN (A INDEX (TABLE2_$_VALUE2), T INDEX (TABLE1_$_VALUE1))
Is it even possible without using stored procedure?
--
Virgo Pärna
virgo.parna@...
UPDATE TABLE1 T
SET T.VALUE1 = NULL
WHERE
T.VALUE1 IN (SELECT A.VALUE1 FROM TABLE2 A WHERE VALUE2 = ?)
But I'd like to do it so, that it uses indexes, like
SELECT T.*
FROM TABLE1 T JOIN TABLE2 A ON T.VALUE1 = A.VALUE1
WHERE A.VALUE2 = ?
There are indexes on T.VALUE1 and A.VALUE2, so the plan is something like
PLAN JOIN (A INDEX (TABLE2_$_VALUE2), T INDEX (TABLE1_$_VALUE1))
Is it even possible without using stored procedure?
--
Virgo Pärna
virgo.parna@...