Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert data from Table1 one field into Table2

Status
Not open for further replies.

serino

Programmer
Feb 13, 2003
107
US
Hi, I need some help here. I am trying to insert "NORDNUM" field from table2 into table1 NORDNUM field.

I have tried doing this, but it will only insert the matched ORDNUM. Any Ideas?

UPDATE Table1 INNER JOIN Table2 ON Table1.ORDNUM = Table2.ORDNUM SET Table1.NORDNUM = Table2.ORDNUM;


Table1 (Key1 is autonumber)
KEY1 NORDNUM ORDNUM
1 23435
2 34656
3 24675
4 74521

Table2 (Key2 is an autonumber)
KEY2 NORDNUM
4 23435
5 34045
6 03945

Final outcome should look like this.

Table1 (Key1 is autonumber)
KEY1 NORDNUM ORDNUM
1 23435 23435
2 34045 34656
3 03945 24675
4 74521



 
Maybe I'm not seeing it, but how do you know that table2 key2 = 5 "belongs" to table1 key1 = 2? Because they are both the "second" record in your example data? Can't work that way.

Leslie

Anything worth doing is a lot more difficult than it's worth - Unknown Induhvidual

Essential reading for database developers:
The Fundamentals of Relational Database Design
Understanding SQL Joins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top