title: "key column doesn't exist in table"
body: <p>I'm making a database in MySQL in class and I'm having trouble adding foreign keys to my tables. I already added most of the foreign keys to my tables when I created the tables but obviously I couldn't add all of them in the creation process. I'm trying to add the remaining foreign keys with the below method.</p>
  
  <pre><code>ALTER TABLE ORDERS 
  ADD FOREIGN KEY (customer_sid) REFERENCES CUSTOMER(SID);
  </code></pre>
  
  <p>For some reason the error message listed in the title keeps popping up. The code is below.  I can see the tables are coming out a bit funny but if you read them from left to right you can see what it says. What do you think? </p>
  
  <pre><code>mysql&gt; show columns from games;
  +------------+-------------+------+-----+---------+----------------+
  | Field      | Type        | Null | Key | Default | Extra          |
  +------------+-------------+------+-----+---------+----------------+
  | gameID     | int(11)     | NO   | PRI | NULL    | auto_increment |
  | videoGames | varchar(30) | NO   |     | NULL    |                |
  | year       | int(11)     | NO   |     | NULL    |                |
  | genreID    | int(11)     | NO   | MUL | NULL    |                |
  | companyID  | int(11)     | NO   | MUL | NULL    |                |
  | directorID | int(11)     | NO   | MUL | NULL    |                |
  +------------+-------------+------+-----+---------+----------------+
  6 rows in set (0.01 sec)
  
  mysql&gt; show columns from consoles;
  +--------------+-------------+------+-----+---------+----------------+
  | Field        | Type        | Null | Key | Default | Extra          |
  +--------------+-------------+------+-----+---------+----------------+
  | consoleID    | int(11)     | NO   | PRI | NULL    | auto_increment |
  | console      | varchar(20) | NO   |     | NULL    |                |
  | yearReleased | int(11)     | NO   |     | NULL    |                |
  +--------------+-------------+------+-----+---------+----------------+
  3 rows in set (0.01 sec)
  
  mysql&gt; alter table games
      -&gt; add foreign key(consoleID) references consoles(consoleID);
  ERROR 1072 (42000): Key column 'consoleID' doesn't exist in table
  </code></pre>