Link to home
Start Free TrialLog in
Avatar of Larry Vollmer
Larry Vollmer

asked on

Copy column from one table to another

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?
Avatar of snoyes_jw
snoyes_jw
Flag of United States of America image

UPDATE master JOIN latlon USING (hhid) SET master.latitude = latlon.latitude, master.longitude = latlon.longitude;
UPDATE master, latlon SET master.latitude=latlon.latitude, master.longitude=latlon.longitude WHERE master.hhid=latlon.hhid;
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I guess snoyes and todd's suggestions are valid also (if not "identical") ...
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!
Avatar of Larry Vollmer
Larry Vollmer

ASKER

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.
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!
I will post over there, thanks
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...
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.

https://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.
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...