0
create table products
( 
  Product_ID varchar(30) not null,
  Product_Name varchar(30) not null,
  Price float not null,
  name varchar(30),
  Description varchar(200) not null,
  Brand varchar(30),
  Image varchar(30),
  Primary key(Product_ID),
  Foreign key(name) REFERENCES category(name)
); 
Joachim Isaksson
  • 176,943
  • 25
  • 281
  • 294
HashibulHasan
  • 17
  • 1
  • 2
  • You may want to add some more details on your actual problem, for example how `name` is declared in `category`. – Joachim Isaksson Jul 16 '16 at 07:41
  • Create backup of category and product table data then truncate both table data...Now apply foreign key and then fill correct data which one should be related with references. – Piyush Gupta Jul 16 '16 at 09:01
  • Possible duplicate of [MySQL Error 1215: Cannot add foreign key constraint](http://stackoverflow.com/questions/16969060/mysql-error-1215-cannot-add-foreign-key-constraint) – Gilad Green Jul 17 '16 at 07:45

0 Answers0