Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2011
    Posts
    1

    Unanswered: 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 19:51.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    UPDATE Database1.users1
    INNER
      JOIN Database2.users2
        ON Database2.users2.userid2 = Database1.users1.userid1
       SET Database2.users2.data2 = Database1.users1.data1
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •