I have table products and table brands.I want to do one to many relationship. brand has many products.
And this sample of data in product
And this sample of data in brands
I try to add foreign key .by this mysql statment
ALTER TABLE products ADD CONSTRAINT fk_brand_id FOREIGN KEY (brand_id) REFERENCES brands(brand_id)
I get this error
#1005 - Can't create table `larashop`.`#sql-dd4_77` (errno: 150 "Foreign key constraint is incorrectly formed") (Details…)
Please anyone help me