Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: update with a join

Re: update with a join

From: Libor Štefek <lstefek_at_logis.cz>
Date: Thu, 26 Oct 2000 10:34:29 +0200
Message-ID: <39F7EC95.28C49B06@logis.cz>

NoSpam wrote:

> UPDATE tbl1 t1
> SET t1.col0 = 0
> WHERE
> t1.col1, t1.col2 in (SELECT t2.col1, t2.col2 from tbl2 t2)
>
> Both col1 and col2 are indexed. Basically, the two conditions on t1 are
> taken from the result set of the subquery. I couldn't get this to work
> unless I concatenate the two conditions into one single column as shown

If col1 or col2 is can contain null values, then you may use something like this:

    UPDATE tbl1 t1

        SET t1.col0 = 0
        WHERE
            nvl(t1.col1,'-null-'), t1.col2 in (SELECT nvl(t2.col1,'-null-), t2.col2 from tbl2 t2)

Libor Received on Thu Oct 26 2000 - 03:34:29 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US