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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Update Query - Help Needed Please

Re: Update Query - Help Needed Please

From: <michael_bialik_at_my-deja.com>
Date: Sat, 28 Aug 1999 12:51:19 GMT
Message-ID: <7q8m06$7jb$1@nnrp1.deja.com>


In article <37C699B0.A6CE06DC_at_ford.invalid>,   dkotecha_at_ford.com wrote:
> This seems quite complex to me as I do not often write updates.
> Hopefully someone can help.
>
> The following select query shows me the rows that I need to update.
The
> problem is the correct syntax for turning it into an update query.
>
> SELECT t1.date
> FROM t1, t2, t3
> WHERE
> t1.date IS NULL
> and t1.id=t2.id
> and t2.date IS NOT NULL
> and t1.id=t3.id
> and t3.name IS NOT NULL
>
> Now this query will give me a whole set of NULL dates as the result.
> What I need to do is to update those dates (t1.date) to t2.date only
for
> the dates returned by the above query. All three tables are linked by
> id, a unique key.
>
> Any help or advice will be greatly appreciated. Thanks in advance,
>
> Dipen
>

Hi.

 If I understood you correctly - you need to reset  T2.DATE field to NULL.

 Try following :
 UPDATE t2 SET date = NULL
 WHERE t2.id IN ( SELECT t1.id

                  FROM t1, t2, t3
                  WHERE
                   t1.date IS NULL
                   and t1.id=t2.id
                   and t2.date IS NOT NULL
                   and t1.id=t3.id
                   and t3.name IS NOT NULL )

 Good luck. Michael.

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't. Received on Sat Aug 28 1999 - 07:51:19 CDT

Original text of this message

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