title: Migrate dataset from two MySQL tables where auto increment id key is the relation
body: <p>I have two MySQL tables in my <code>development</code> database. (Some might recognize Drupal here..)</p>
  
  <pre><code>CREATE TABLE `node` (
   `nid` int(10) unsigned NOT NULL AUTO_INCREMENT,
   `vid` int(10) unsigned NOT NULL DEFAULT '0',
   PRIMARY KEY (`nid`),
   UNIQUE KEY `vid` (`vid`),
  );
  
  CREATE TABLE `content_type_fenykep` (
    `vid` int(10) unsigned NOT NULL DEFAULT '0',
    `nid` int(10) unsigned NOT NULL DEFAULT '0',
    `field_fenykep_fid` int(11) DEFAULT NULL,
    `field_galeria_nid` int(10) unsigned DEFAULT NULL,
     PRIMARY KEY (`vid`),  KEY `nid` (`nid`),
     KEY `field_galeria_nid`    (`field_galeria_nid`)
   );
  
  CREATE TABLE `files` (
    `fid` int(10) unsigned NOT NULL AUTO_INCREMENT,
    `uid` int(10) unsigned NOT NULL DEFAULT '0',
    `filename` varchar(255) NOT NULL DEFAULT '', 
    `filepath` varchar(255) NOT NULL DEFAULT '',
     PRIMARY KEY (`fid`),  KEY `uid` (`uid`),
   );
  </code></pre>
  
  <p>They are connected by the <code>content_type_fenykep.field_fenykep_fid</code> field that refers to <code>files.fid</code>.</p>
  
  <p>I would like to migrate a set of records from <code>content_type_fenykep</code> with the appropriate <code>files</code> records as well to a different, let's say <code>production</code> database. My problem is that I need to change the <code>fid</code>s in every <code>content_type_fenykep</code> record because both tables have their different autoincrement states.</p>
  
  <p>My first idea would be writing a program for this problem, but I am wondering if this can be solved only with MySQL or not.</p>
  
  <p>Do you have any ideas how this could be achieved?</p>