473,508 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How best to update client table records with a dozen or so changed records from another table?

MLH
We have a table (tblClients) with several thousand records.
Because of organizational structure, changes to those records
are maintained in a separate database. Weekly, about a dozen
or so clients change phone numbers, addresses or something.
The table housing changed client data is tblChangedClients. It
is IDENTICAL to tblClients - except for the table name.

We have been taking the recs from tblChangedClients and
manually pasting the changes into tblClients. The common,
unique key field in both tables is [cSSN]. The tables contain
the usual info fields (name, addr, city, state, zip, etc...) as well
as the cSSN field. I have tblChangedClients attached to my
database in which tblClients is local. Can a query be used to
update the dozen rec's in tblClients that need updating. Or, do
I have to do the changes one-by-one using DAO?

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Nov 13 '05 #1
2 1396
On Tue, 14 Dec 2004 10:22:21 -0500, MLH <CR**@NorthState.net> wrote:
We have a table (tblClients) with several thousand records.
Because of organizational structure, changes to those records
are maintained in a separate database. Weekly, about a dozen
or so clients change phone numbers, addresses or something.
The table housing changed client data is tblChangedClients. It
is IDENTICAL to tblClients - except for the table name.

We have been taking the recs from tblChangedClients and
manually pasting the changes into tblClients. The common,
unique key field in both tables is [cSSN]. The tables contain
the usual info fields (name, addr, city, state, zip, etc...) as well
as the cSSN field. I have tblChangedClients attached to my
database in which tblClients is local. Can a query be used to
update the dozen rec's in tblClients that need updating. Or, do
I have to do the changes one-by-one using DAO?

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Hi
You can certainly use queries, in general you need three:

delete clients who no longer appear (if this is required)
DELETE tblClients.*
FROM tblClients LEFT JOIN tblChangedClients ON tblClients.cSSN =
tblChangedClients.cSSN
WHERE tblChangedClients.cSSN Is Null

update fields xxx for clients which are in both tables
UPDATE tblClients INNER JOIN tblChangedClients ON tblClients.cSSN =
tblChangedClients.cSSN SET tblClients.xxx = tblChangedClients.xxx

insert new clients
INSERT INTO tblClients ( cSSN, xxx )
SELECT tblChangedClients.cSSN, tblChangedClients.xxx
FROM tblClients RIGHT JOIN tblChangedClients ON tblClients.cSSN =
tblChangedClients.cSSN
WHERE tblClients.cSSN Is Null

David
Nov 13 '05 #2
MLH
Thanks, David...
All I need is to update clients that exist in both tables, so I'll
try your 2nd recommendation and let you know how it turns
out. I appreciate the reply!

<snip>

Hi
You can certainly use queries, in general you need three:

delete clients who no longer appear (if this is required)
DELETE tblClients.*
FROM tblClients LEFT JOIN tblChangedClients ON tblClients.cSSN =
tblChangedClients.cSSN
WHERE tblChangedClients.cSSN Is Null

update fields xxx for clients which are in both tables
UPDATE tblClients INNER JOIN tblChangedClients ON tblClients.cSSN =
tblChangedClients.cSSN SET tblClients.xxx = tblChangedClients.xxx

insert new clients
INSERT INTO tblClients ( cSSN, xxx )
SELECT tblChangedClients.cSSN, tblChangedClients.xxx
FROM tblClients RIGHT JOIN tblChangedClients ON tblClients.cSSN =
tblChangedClients.cSSN
WHERE tblClients.cSSN Is Null

David


Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1708
by: yvan | last post by:
Approximately once a month, a client of ours sends us a bunch of comma-delimited text files which I have to clean up and then import into their MS SQL database. All last week, I was using a Cold...
16
16975
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
9
4333
by: Dom Boyce | last post by:
Hi First up, I am using MS Access 2002. I have a database which records analyst rating changes for a list of companies on a daily basis. Unfortunately, the database has been set up (by my...
10
2778
by: DaveDiego | last post by:
I've had a user delete one of the client records, I do have a version of the DB with all records intact before the deletion occured. Whats the best approach to getting all the related records in...
9
1536
by: Kevin Hodgson | last post by:
I'm experiencing a strange Dataset Update problem with my application. I have a dataset which has a table holding a set of customer information records. (address, contact, info, etc.) I have a...
30
3354
by: Charles Law | last post by:
Here's one that should probably have the sub-heading "I'm sure I asked this once before, but ...". Two users are both looking at the same data, from a database. One user changes the data and...
5
1538
by: =?Utf-8?B?Q2hyaXM=?= | last post by:
Hi, I need to store lots of product images. I was thinking of storing the paths in the database but overtime it may become cumbersome as I'll be dealing with lots of images. I would need to...
3
1356
by: Kevin | last post by:
I have a Windows Forms app with a form that displays/updates student data. When it activates I fill a DataTable with just the names of the students from a table of about 10,000 names. I have...
14
1334
by: thetaamommy | last post by:
CREATE Table CO(CustID int, OfficerSID varchar(10), OfficerRank tinyint) Insert Into CO VALUES (1, 'KURT', 1) Insert Into CO VALUES (1, 'ALEX', 2) Insert Into CO
0
7123
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7382
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7042
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7495
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4707
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3181
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1556
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
418
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.