title: Why do I get an error while adding a foreign key constraint to a table?
body: <p>Table wp_users wordpress have this syntax:</p>
  
  <pre><code>CREATE TABLE `wp_users` (
    `ID` bigint(20) unsigned NOT NULL auto_increment,
    `user_login` varchar(60) NOT NULL default '',
    `user_pass` varchar(64) NOT NULL default '',
    `user_nicename` varchar(50) NOT NULL default '',
    `user_email` varchar(100) NOT NULL default '',
    `user_url` varchar(100) NOT NULL default '',
    `user_registered` datetime NOT NULL default '0000-00-00 00:00:00',
    `user_activation_key` varchar(60) NOT NULL default '',
    `user_status` int(11) NOT NULL default '0',
    `display_name` varchar(250) NOT NULL default '',
    PRIMARY KEY  (`ID`),
    KEY `user_login_key` (`user_login`),
    KEY `user_nicename` (`user_nicename`)
  ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;
  </code></pre>
  
  <p>And I wanted to integrate a system already implemented for wordpress but I'm having problems with foreign keys to connect the table wp_users.</p>
  
  <p>I have this table:</p>
  
  <pre><code>CREATE TABLE attach (
    attach_id int unsigned NOT NULL auto_increment,     
    email varchar(60) NOT NULL default '',
    PRIMARY KEY  (attach_id),
    FOREIGN KEY (email) REFERENCES wp_users(user_login_key) 
    ON UPDATE CASCADE ON DELETE CASCADE
  )Engine=INNODB;
  </code></pre>
  
  <p>I wanted to connect to user_email from wp_users, but user_login and user_email will be the same.. And it's totally impossible to define attach_id as a FK to ID from wp_users, due to other situations in other tables.</p>
  
  <p>When I submit gives error # 1005</p>