-2
     CREATE TABLE IF NOT EXISTS super(
    id      int (20) PRIMARY KEY AUTO_INCREMENT,
    cod     varchar(5)
    );


    CREATE TABLE IF NOT EXISTS super2(
    id2      int (20) PRIMARY KEY AUTO_INCREMENT,
    cod2     varchar(5),
    FOREIGN KEY (cod2) REFERENCES super(cod)
    );

I cant create share tables please help and thanks with FOREIGN KEY errno 150...

Leigh
  • 28,765
  • 10
  • 55
  • 103
  • Welcome to Stack Overflow! Please be sure to search the archives before posting. This is a duplicate of [MySQL Creating tables with Foreign Keys giving errno: 150](http://stackoverflow.com/questions/1457305/mysql-creating-tables-with-foreign-keys-giving-errno-150) – Leigh Sep 30 '14 at 01:09

1 Answers1

4

It is because cod is not the primary key in the super table.

Leigh
  • 28,765
  • 10
  • 55
  • 103
4af2e9eb6
  • 682
  • 3
  • 7
  • 20