Hi
Am trying to create a table called (sub_categories ). This table have two columns :
sub_category_id : Primary (int)
parent_category id: not null (int)
Both tables reference the column (id) from categories table. When i try to creating the table it gives me the error :
ERROR 1005: Can't create table 'shoppingcart.s ub_categories' (errno: 150)
Here is the SQL syntax
So , what's the wrong ? am using MySQL 5.0.7
Am trying to create a table called (sub_categories ). This table have two columns :
sub_category_id : Primary (int)
parent_category id: not null (int)
Both tables reference the column (id) from categories table. When i try to creating the table it gives me the error :
ERROR 1005: Can't create table 'shoppingcart.s ub_categories' (errno: 150)
Here is the SQL syntax
Code:
CREATE TABLE `shoppingcart`.`sub_categories` (
`sub_category_id` INT NOT NULL ,
`parent_category_id` INT NOT NULL ,
PRIMARY KEY (`sub_category_id`) ,
INDEX `sub_categories_categories` (`sub_category_id` ASC, `parent_category_id` ASC) ,
CONSTRAINT `sub_categories_categories`
FOREIGN KEY (`sub_category_id` , `parent_category_id` )
REFERENCES `shoppingcart`.`categories` (`id` , `id` )
ON DELETE NO ACTION
ON UPDATE CASCADE)
ENGINE = InnoDB
Comment