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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using SQL to Update two tables

Status
Not open for further replies.

GenieTR

IS-IT--Management
Jan 21, 2003
28
I have two tables, same structure, trying to update one of the field from table B to table A. In table A the field in question have missing data, whereas, in table B there is no missing data in that particular field.

I create a update sql statement that goes like this:

UPDATE client1 INNER JOIN client11 ON client1.clientID = client11.clientID SET client11.mcssid = client1.mcssid WHERE client11.mcssid <> client1.mcssid;

When I click view, a dialog box appear ask me for mcssid. How do you run this sql or how do you go about updating the table that have missing data in the mcssid field?

Thanks in advance
 
Do you need the where clause in your statement?

If you update every row, it will give you the desired result, because it will update the existing rows, to exactly what they currently are.
 
Even removing the WHERE clause, it still prompt me for a value. How would write the update query, to update the field that is blank with the value from the other table.
 
Looking at your query again, you start out by saying update client1. Then in your set clause you have set client11 = client1.

If you are tyring to update table client1 then you need to reverse the set clause to

set client1.mcssid = client11.mcssid

and if you are trying to update client11 then you need to switch the first part of your update statement to

update client11 inner join client1 on .....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top