Solved

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

Posted on 2011-09-29
6
301 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 

Author Comment

by:maximus81
ID: 36817999
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
ID: 36818341
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
ID: 36818565
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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

Author Comment

by:maximus81
ID: 36891384
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
ID: 36891397
I got it:

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

Author Closing Comment

by:maximus81
ID: 36891398
Thanks for your help
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

622 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