Re: Update statement

From: Damjan S. Vujnovic <damjan_at_NOSPAMgaleb.etf.bg.ac.yu>
Date: Sat, 23 Nov 2002 08:45:36 +0100
Message-ID: <arnbie$eqd$1_at_news.etf.bg.ac.yu>


> I thought of option 1 but option 2 is better (well, maybe. Depends). If
> there is more then one row in sqlloadtable with the same key as a row in
> basetable, then option 1 will fail.

How about:

UPDATE b
SET b.field1 = (

    SELECT t.field1
    FROM sqlloadtable t
    WHERE t.key = b.key)
WHERE b.key IN (

    SELECT key
    FROM sqlloadtable) AND (
    SELECT COUNT(*)
    FROM sqlloadtable t
    WHERE t.key = b.key) = 1

Regards,
Damjan S. Vujnovic

University of Belgrade
School of Electrical Engineering
Department of Computer Engineering & Informatics Belgrade, Yugoslavia

http://galeb.etf.bg.ac.yu/~damjan/ Received on Sat Nov 23 2002 - 08:45:36 CET

Original text of this message