🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.interbase.sql
Article #749

Re: Update one table based on data in another

#749
From: Bill Todd
Date: Mon, 25 Jun 2007 23:00
20 lines
1705 bytes
I suspect that you have rows in Customers that do not exist in
Customers_Imported and that you want to update only those rows in
Customers that have a matching record in Customers_Imported with the
values from Customers_Imported. If so, something like the following
(untested) should work.

Yes, it seems unnecessarily complex to have to repeat the subquery for
each field but that's what you have to do.

UPDATE CUSTOMERS
SET NAME = (SELECT customers_imported.name
FROM customers_imported
WHERE customers.account_ref = customers_imported.account_ref)
WHERE EXISTS
  ( SELECT 1
    FROM customers_imported
    WHERE customers.account_ref = customers_imported.account_ref);

-- 
Bill Todd (TeamB)
Technical Details
Message-ID: <46804923$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder3.cambrium.nl!feed.tweaknews.nl!newsfeed.kamp.net!newsfeed.kamp.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <bec083t4td4iqapnt5pu2sm66tp172oudu@4ax.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,2270d561f33be473
X-Google-Attributes: gid114a0e,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Bill Todd" <no@no.com>
Subject: Re: Update one table based on data in another
Newsgroups: borland.public.interbase.sql
References:  <bec083t4td4iqapnt5pu2sm66tp172oudu@4ax.com>
Organization: The Database Group, Inc.
User-Agent: XanaNews/1.18.1.6
X-Face: ":yn4zt^A_dn>6~{YJmu^B\'4w)e:apPM\VC=Dvf&*tASxX9|BYczkFd$xr.$vNSZ[3Uobr p]c4\+\l){!WQI.$]veP({HLd;CDYH?iN
NNTP-Posting-Host: 216.207.211.19
Message-ID: <46804923$1@newsgroups.borland.com>
Date: 25 Jun 2007 16:00:51 -0700
X-Trace: newsgroups.borland.com 1182812451 216.207.211.19 (25 Jun 2007 16:00:51 -0700)
Lines: 20
X-Authenticated-User: btodd
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder3.cambrium.nl!feed.tweaknews.nl!newsfeed.kamp.net!newsfeed.kamp.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail