Querying a table to modify another table 
Author Message
 Querying a table to modify another table

What is the best way to modify a field in one database
based on values in another? I need to scan all the
records in two large tables and apply the following
criteria:

For each record in TableA,
if field1 and field2 of TableA match field1 and field2 of
TableB,
then copy the value of field6 in TableA to field6 in
TableB

Thanks for any suggestions you can give me.

Jim Levitt



Tue, 11 Jan 2005 20:34:20 GMT  
 Querying a table to modify another table
Why would you need field6 in two places if they both aren't updated at the
same time?  Can't you just establish a relationship between the the two
tables and get the value from the one copy of field6 whenever needed?

Mich


Quote:
> What is the best way to modify a field in one database
> based on values in another? I need to scan all the
> records in two large tables and apply the following
> criteria:

> For each record in TableA,
> if field1 and field2 of TableA match field1 and field2 of
> TableB,
> then copy the value of field6 in TableA to field6 in
> TableB

> Thanks for any suggestions you can give me.

> Jim Levitt



Tue, 11 Jan 2005 21:06:56 GMT  
 Querying a table to modify another table
You might do this using an update query whose SQL looked something like
this:

UPDATE TableA
INNER JOIN TableB
ON (TableA.field2 = TableB.field2)
AND (TableA.field1 = TableB.field1)
SET TableB.field6 = [TableA].[field6];


Quote:
> What is the best way to modify a field in one database
> based on values in another? I need to scan all the
> records in two large tables and apply the following
> criteria:

> For each record in TableA,
> if field1 and field2 of TableA match field1 and field2 of
> TableB,
> then copy the value of field6 in TableA to field6 in
> TableB

> Thanks for any suggestions you can give me.

> Jim Levitt



Tue, 11 Jan 2005 21:26:55 GMT  
 Querying a table to modify another table
I'm normalizing tables. I will eventually delete field1
and field2 in one table so that I can use field6 as the
relational link in a 1 to many relationship.
Quote:
>-----Original Message-----
>Why would you need field6 in two places if they both

aren't updated at the
Quote:
>same time?  Can't you just establish a relationship
between the the two
>tables and get the value from the one copy of field6
whenever needed?

>Mich



>> What is the best way to modify a field in one database
>> based on values in another? I need to scan all the
>> records in two large tables and apply the following
>> criteria:

>> For each record in TableA,
>> if field1 and field2 of TableA match field1 and field2
of
>> TableB,
>> then copy the value of field6 in TableA to field6 in
>> TableB

>> Thanks for any suggestions you can give me.

>> Jim Levitt

>.



Wed, 12 Jan 2005 01:51:39 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Help newbie modify table and referance table together

2. Create multiple tables from a single Make-Table Query

3. Make Table Query from Linked SQL Table

4. Permissions on tables created by make-table queries

5. Empty tables in a multi-tables query

6. Empty tables in a multi-tables query

7. Enumerate table and query names in ADO excluding system tables

8. Make Table Query vs Append Query

9. Newbiw having problems with Permanent QueryDef: Query input must contain at least one table or query

10. Make-Table queries and Append Queries

11. Unable to delete from query if more than one table in query

12. modify data in Access table with DAO?

 

 
Powered by phpBB® Forum Software