Need help with SQL commands

5 pts.
Tags:
SQL
SQL commands
hye there i need some guidance on sql command. i accidently update all data in 1 table to be as one data only. may i know how i want to revert back to the previous data. or at least what is the sql command to use to make the data in that table updated according to their own data by referring to another table. fyi, the another table has one column which match another column in that affected table. Thank you in advanced for ur help....
ASKED: January 30, 2009  5:29 AM
UPDATED: February 2, 2009  5:14 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

You will need to key off a common field and replace the bad data in the first table with the corresponding good data from the second table.

To illustrate:

<pre>
Table 1 Table 2
———- ————
Table1.Name Table2.Name
Table1.Address Table2.Address
Table1.Phone Table2.Email
</pre>

Use a query similar to this:

UPDATE Table1
SET Table1.Address = Table2.Address
FROM Table1 INNER JOIN Table2 on (Table1.Name = Table2.Name)

Best wishes,
Daniel

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following