2

I have 2 tables.

manifast

+-------------+------------------+------+-----+---------+----------------+
| Field       | Type             | Null | Key | Default | Extra          |
+-------------+------------------+------+-----+---------+----------------+
| manifast_id | int(11) unsigned | NO   | PRI | NULL    | auto_increment |
| description | text             | NO   |     | NULL    |                |
| title       | text             | NO   |     | NULL    |                |
+-------------+------------------+------+-----+---------+----------------+

day_sequence;

+-----------------+------------------+------+-----+---------+----------------+
| Field           | Type             | Null | Key | Default | Extra          |
+-----------------+------------------+------+-----+---------+----------------+
| day_sequence_id | int(11) unsigned | NO   | PRI | NULL    | auto_increment |
| day_number      | int(11)          | NO   |     | NULL    |                |
| day_start       | int(11)          | NO   |     | NULL    |                |
| manifast_id     | int(11)          | NO   |     | NULL    |                |
+-----------------+------------------+------+-----+---------+----------------+

4 rows in set (0.00 sec)

I wanna connect those two columns and use this command.

ALTER TABLE day_sequence
ADD CONSTRAINT fk_manifast
FOREIGN KEY (manifast_Id)
REFERENCES manifast(manifast_Id);

and it show this error.How can i solve?

The specified relation was unable to be created.

MySQL said: Can't create table 'projectx.#sql-3e0_4' (errno: 150)

Barmar
  • 741,623
  • 53
  • 500
  • 612
  • What table storage engine are these tables using? Could you please post the output of `SHOW CREATE TABLE manifast;` and `SHOW CREATE TABLE day_sequence;`? – Joel Cox Dec 23 '14 at 03:56
  • possible 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) – AndySavage Dec 23 '14 at 03:57

2 Answers2

0

Manifast_id also needs to be unsigned int, looks like it is not.

Ossip
  • 1,046
  • 8
  • 20
0

Try fixing the other manifast id to unsigned then try doing it like this

ALTER TABLE day_sequence ADD CONSTRAINT fk_manifast FOREIGN KEY (manifast_Id) REFERENCES (manifast.manifast_Id);