Solved

Need to move multiple columns from one database to another by username

Posted on 2011-09-29
6
296 Views
Last Modified: 2012-05-12
I have two databases and I want to update three of the columns in the second database using three columns from the first by what username it is.

First database

Database1 columns monone, montwo, asignedto

Database2 columns model, size, asignedto

What i need to do is have is monone -> model, montwt-> size, Database1.asignedto->Database2.asignedto by what the asignedto is. I have been researching this and not sure what I am doing.

0
Comment
Question by:maximus81
  • 4
  • 2
6 Comments
 

Author Comment

by:maximus81
Comment Utility
This is what i have so far and its not working:


UPDATE `monitors` SET model = atsassets.monone, size = atsassets.montwo, asignedto = atsassets.asignedto FROM atsassets where id = atsassets.id

Open in new window

0
 
LVL 24

Expert Comment

by:johanntagle
Comment Utility
First of all, call them Tables - a database consists of one or more tables.

update Table1 t1, Table2 t2 set t1.monoone=t2.model, t1.montwt=t2.size, t1.asignedto=t2.asignedto where t1.username=t2.username

0
 
LVL 24

Accepted Solution

by:
johanntagle earned 250 total points
Comment Utility
Sorry, was still sleepy a while back and didn't really read your trial statement.  It should be:

UPDATE monitors, atsassets SET monitors.model = atsassets.monone, monitors.size = atsassets.montwo, monitors.asignedto = atsassets.asignedto where monitors.id = atsassets.id
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:maximus81
Comment Utility
I actually need to insert instead of update. Here is what I have so far but its not working.

insert into monitors select monone, montwo, asignedto from atsassets
0
 

Author Comment

by:maximus81
Comment Utility
I got it:

insert into monitors(model, size, asignedto) select monone, montwo, asignedto from atsassets
0
 

Author Closing Comment

by:maximus81
Comment Utility
Thanks for your help
0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now