Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 305
  • Last Modified:

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

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
maximus81
Asked:
maximus81
  • 4
  • 2
1 Solution
 
maximus81Author Commented:
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
 
johanntagleCommented:
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
 
johanntagleCommented:
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
Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 
maximus81Author Commented:
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
 
maximus81Author Commented:
I got it:

insert into monitors(model, size, asignedto) select monone, montwo, asignedto from atsassets
0
 
maximus81Author Commented:
Thanks for your help
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now