title: How to add a foreign key constraint in existing table
body: <p>I am having 2 tables first is <code>smsusers(id,fname,lname,userid)</code>
  'id' is primary key,
  <code>userid</code> is unique key</p>
  
  <pre><code>address_detail(id,address,type);
  </code></pre>
  
  <p>Here I want to add <code>userid</code> of <code>smsusers</code> as foreign key to <code>address_detail</code> table.</p>
  
  <p>for that i added a column to <code>address_detail</code> as <code>user_id</code></p>
  
  <pre><code>ALTER TABLE address_detail add user_id INT( 20 )  default NULL;
  </code></pre>
  
  <p>Now I am adding foreign key constraint to table</p>
  
  <pre><code>ALTER TABLE `address_detail` add CONSTRAINT address_detail_fk FOREIGN KEY (user_id) 
  REFERENCES smsusers ('userid') ON UPDATE CASCADE ON DELETE CASCADE;
  </code></pre>
  
  <p>This step is showing following error</p>
  
  <pre><code>#1064 - You have an error in your SQL syntax; 
  check the manual that corresponds to your MySQL server
  version for the right syntax to use near ''userid') ON 
  UPDATE CASCADE ON DELETE CASCADE' at line 1
  </code></pre>