Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-09-29
6
Medium Priority
?
302 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 1000 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
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

 

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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

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 …
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
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…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

730 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