Skip navigation links

MySQL Forums :: Foreign Keys (Referential Integrity) :: error in inserting to foreign key column from mastert table


Advanced Search

error in inserting to foreign key column from mastert table
Posted by: Radhakant Samal ()
Date: November 20, 2010 01:20AM

i have createdd two tables having foreign key relationship the tables are
CREATE TABLE fee_class_category (
class_category_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
class_from SMALLINT UNSIGNED NULL,
class_to SMALLINT UNSIGNED NULL,
PRIMARY KEY(class_category_id)
)
TYPE=InnoDB;
CREATE TABLE fee_class_category_name (
class_category_name VARCHAR(15) NOT NULL,
class_category_id INTEGER UNSIGNED NOT NULL,
class_category_name_id SMALLINT UNSIGNED NULL,
PRIMARY KEY(class_category_name),
FOREIGN KEY(class_category_id)
REFERENCES fee_class_category(class_category_id)
ON DELETE NO ACTION
ON UPDATE NO ACTION
)
TYPE=InnoDB;

when i am trying to insert values from class_category_id column from fee_class_category into class_category_id column of fee_class_category_name table. it is showing below error
Error Code : 1062
Duplicate entry '' for key 1

Options: ReplyQuote


Subject Views Written By Posted
error in inserting to foreign key column from mastert table 1859 Radhakant Samal 11/20/2010 01:20AM
Re: error in inserting to foreign key column from mastert table 948 Chad Bourque 11/20/2010 12:22PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.