Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Update Query - Help Needed Please
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