|
-
Mar 4th, 2004, 07:05 AM
#1
Thread Starter
Addicted Member
SQL Update
I have two tables A and B each table has three fields 1,2 and 3.
What i need to do is update table A field 3 with the value of table B field 3 where A.1 = B.1 and A.2 = B.2 The problem is i have know idea of the SQL statment i need to achive this.
-
Mar 4th, 2004, 08:04 AM
#2
In case of msSQL
VB Code:
update TableA set TableA.FieldC = TB.fieldC from TableA TA, TableB TB where TA.PrimKey = TB.ForeignKey
-
Mar 4th, 2004, 08:06 AM
#3
Fanatic Member
Try something like this:
UPDATE Table_A
SET Table_A.Field_3 = Table_B.Filed_3
WHERE Table_A.Field_1 = Table_B.Field_1
AND Table_A.Field_2 = Table_B.Field_2
Do canibals not eat clowns because they taste funny? 
-
Mar 4th, 2004, 08:34 AM
#4
Thread Starter
Addicted Member
doofusboy, that is the method i have tried but it just requests a value for TableA.Field_1.
I forgot to add that i am using Access
-
Mar 4th, 2004, 08:40 AM
#5
Make sure the criteria would return only one record from table B.
-
Mar 4th, 2004, 08:43 AM
#6
Thread Starter
Addicted Member
I dont want to update just one record, i want to update all the matching records.
-
Mar 4th, 2004, 11:14 AM
#7
"but it just requests a value for TableA.Field_1."
Then Field_1 is not a fieldname in TableA
Try this MS Access syntax
Code:
UPDATE TableA
INNER JOIN TableB ON TableB.Field1 = TableA.Field1 And TableB.Field2 = TableA.Field2
SET TableA.Field3 = TableB.Field3;
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|