If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > SQL Query to copy from one database to another

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-16-11, 18:47
jogger jogger is offline
Registered User
 
Join Date: Feb 2011
Posts: 1
SQL Query to copy from one database to another

Both database are on the same server.

Need to copy data

FROM Database1 > users1 > data1 TO Database2 > users2 > data2
ONLY WHEN
Database2 > users2 > userid2 <<EQUALS>> Database 1 > users1 > userid1

-----------------------------------------------

I dealt with a similiar query before, but not across databases.

The old query I have is below:

Code:
UPDATE forums_drupal_node, wp_posts SET post_author=forums_drupal_node.uid WHERE forums_drupal_node.nid=wp_posts.ID

Last edited by jogger; 02-16-11 at 18:51.
Reply With Quote
  #2 (permalink)  
Old 02-17-11, 05:11
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,535
Code:
UPDATE Database1.users1
INNER
  JOIN Database2.users2
    ON Database2.users2.userid2 = Database1.users1.userid1
   SET Database2.users2.data2 = Database1.users1.data1
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On