title: MySQL Foreign Key constraint error - Failed to add foreign key constraint - error 1822
body: <p>Any help would be greatly appreciated.</p>
  
  <p>I have two tables, "Employee" and "EventPlan".
  For the Create table EventPlan table, when I try to create the table, it is giving me an error in MySQL workbench: </p>
  
  <blockquote>
    <p>Error 1822 - Failed to add the foreign key constraint. Missing index
    for constraint "EmpNo" in the referenced table "employee".</p>
  </blockquote>
  
  <p>You will see in both tables "EmpNo" is included. But I cannot see what I am doing wrong. Please see code below.  </p>
  
  <p>I cannot execute or create the "EventPlan" in My SQL workbench.</p>
  
  <p>I have reviewed both tables, also made the coloumns unique, but cannot find the issue.</p>
  
  <p>EVENT PLAN TABLE</p>
  
  <pre><code>CREATE TABLE Eventplan
  ( PlanNo VARCHAR(8) NOT NULL,
  EventNo VARCHAR(8) UNIQUE NOT NULL,
  Workdate DATE,
  Notes VARCHAR(8),
  EmpNo VARCHAR(8) ,
  CONSTRAINT PK_PlanNo PRIMARY KEY(PlanNo),
  CONSTRAINT EventNo FOREIGN KEY (EventNo)
  REFERENCES Eventrequest(EventNo),
  CONSTRAINT EmpNo FOREIGN KEY (EmpNo)
  REFERENCES Employee(EmpNo)
  );
  </code></pre>
  
  <p>EMPLOYEE TABLE</p>
  
  <pre><code>CREATE TABLE Employee
  (EmpNo VARCHAR(200) UNIQUE NOT NULL,
  EmpName VARCHAR(200) NOT NULL,
  Department VARCHAR(50) NOT NULL,
  Email VARCHAR(20) NOT NULL,
  Phone VARCHAR(20) NOT NULL,
  CONSTRAINT PKEmployee PRIMARY KEY(EmpNo)
  ); 
  </code></pre>