?
Solved

Copy column from one table to another

Posted on 2006-03-20
11
Medium Priority
?
840 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?
0
Comment
Question by:lvollmer
  • 4
  • 4
  • 2
  • +1
11 Comments
 
LVL 33

Expert Comment

by:snoyes_jw
ID: 16240950
UPDATE master JOIN latlon USING (hhid) SET master.latitude = latlon.latitude, master.longitude = latlon.longitude;
0
 
LVL 30

Expert Comment

by:todd_farmer
ID: 16240954
UPDATE master, latlon SET master.latitude=latlon.latitude, master.longitude=latlon.longitude WHERE master.hhid=latlon.hhid;
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 16240958
update master, latlon
  set master.latitude = latlon.latitude, master.longitude = latlon.latitude
where master.hhid = latlon.hhid
 
0
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 16241036
I guess snoyes and todd's suggestions are valid also (if not "identical") ...
0
 
LVL 30

Expert Comment

by:todd_farmer
ID: 16241098
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!
0
 

Author Comment

by:lvollmer
ID: 16241137
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.
0
 
LVL 30

Expert Comment

by:todd_farmer
ID: 16241238
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!
0
 

Author Comment

by:lvollmer
ID: 16241256
I will post over there, thanks
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 16244197
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...
0
 
LVL 30

Expert Comment

by:todd_farmer
ID: 16244238
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.
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 16244412
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...
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month13 days, 18 hours left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question