We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Copy column from one table to another

lvollmer
lvollmer asked
on
Medium Priority
862 Views
Last Modified: 2008-02-01
I have a table called 'latlon' - It has 3 columns - hhid,latitude,longitude

I have another table in the same db called master. It has 30,000 records.

the hhid in master is the same  as the hhid in latlon.

I need to copy the latitude and longitude into the master table where hhid = hhid in table latlon


What is the query to do this?
Comment
Watch Question

Top Expert 2005

Commented:
UPDATE master JOIN latlon USING (hhid) SET master.latitude = latlon.latitude, master.longitude = latlon.longitude;
Top Expert 2006

Commented:
UPDATE master, latlon SET master.latitude=latlon.latitude, master.longitude=latlon.longitude WHERE master.hhid=latlon.hhid;
Billing Engineer
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2009
Commented:
update master, latlon
  set master.latitude = latlon.latitude, master.longitude = latlon.latitude
where master.hhid = latlon.hhid
 

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Guy Hengel [angelIII / a3]Billing Engineer
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2009

Commented:
I guess snoyes and todd's suggestions are valid also (if not "identical") ...
Top Expert 2006

Commented:
Hmm....

You accepted an answer from angelIII that is EXACTLY the same as my earlier post, as best I can tell.  My post is almost identical to snoyes_jw's (although his has uses a JOIN syntax that mine does not).

You should accept the first correct answer.  Can you explain what was wrong with the first two?  If you decide to change your accepted answer, you may post a request to the Support topic area asking that this question be reopened for regrading.

Thanks!

Author

Commented:
Sorry todd, when I clicked the link in the email it defaulted right to angel's post. I did not even see there were answers above the post. I am sorry.
Top Expert 2006

Commented:
No problem - I think snoyes_jw's solution will work and should likely get the credit (although I have never used the JOIN syntax in an UPDATE statement myself).  If you post a request to the Support topic area (it's free), they will reopen the question so that you can accept the correct answer.

Thanks!

Author

Commented:
I will post over there, thanks
Guy Hengel [angelIII / a3]Billing Engineer
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2009

Commented:
todd_farmer >You should accept the first correct answer.
hhmmm... actually, if all the answers are working/correct (and posted in such a small time interval like here), a split points is what should be done...
Top Expert 2006

Commented:
I'm just reiterating what is said in the FAQs:

If a comment posted by an Expert has answered your question, then you should select the Expert's comment as the answer to your question. In case of duplicate or similar comments, you should always select the first comment posted.

http://www.experts-exchange.com/help.jsp#hi68

I'm happy to receive points whenever anybody wants to give them to me, but it sure seems to me like snoyes_jw got the answer right first.  Yes, it stinks to be the second (or third) person posting the same correct solution in a matter of minutes (or less), but I don't read anything that says that points should be split if duplicate answers are given in a short period of time.  If there's something that says to do it that way, please let us know.
Guy Hengel [angelIII / a3]Billing Engineer
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2009

Commented:
I actually agree with you.
however, both #68 and #69 leave the freedom to the questionner to split the points.
And honestly I think the FAQ should be slightly modified for this case...
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.