Chetan, the type of the column user_id is different in your two tables: in the parent table it is UNSIGNED, but signed in the child table. The internal storage format of a signed integer is different from an unsigned integer. That is why adding the child row fails.
I changed now InnoDB-3.23.48 so that it gives an error in CREATE TABLE if the integer type signedness is not consistent in the foreign key declarations. Best regards, Heikki Tuuri Innobase Oy --- Order technical MySQL/InnoDB support at https://order.mysql.com/ See http://www.innodb.com for the online manual and latest news on InnoDB "Chetan Lavti" wrote in message ... > > >-----Original Message----- >From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] >Sent: Thursday, February 07, 2002 2:22 PM >To: Chetan Lavti >Subject: Re: insertion problem !! > > >Your message cannot be posted because it appears to be either spam or >simply off topic to our filter. To bypass the filter you must include >one of the following words in your message: > >sql,query > >If you just reply to this message, and include the entire text of it in >the >reply, your reply will go through. However, you should >first review the text of the message to make sure it has something to do >with MySQL. Just typing the word MySQL once will be sufficient, for >example. > >You have written the following: > >hi, >I have two tables as:=20 >please concentrate on domain_id and INDEX=20 > >Create table ls_domain >( domain_id INT(4) UNSIGNED AUTO_INCREMENT , > domain_addr VARCHAR(80), > domain_name CHAR(50) UNIQUE KEY, > domain_port INT(6) UNSIGNED, > domain_ip VARCHAR(15), > created_by VARCHAR(40), > created_date DATE, > PRIMARY KEY (domain_id) >) TYPE=3DInnoDB; > >I have created and inserted values in it then.. > >Create table ls_user >( > user_id INT(4) UNSIGNED AUTO_INCREMENT , > domain_id INT(4), > INDEX do_id (domain_id), > user_name VARCHAR(30) UNIQUE KEY, > user_flag CHAR(1) , > user_passwd VARCHAR(8) , > user_addr VARCHAR(100), > user_email VARCHAR(50), > created_by VARCHAR(30), > created_date DATE, > FOREIGN KEY (domain_id) REFERENCES ls_domain(domain_id), > PRIMARY KEY (user_id) >) TYPE=3DInnoDB; > >It has also been created. Now when I am inserting values in ls_user it >is giving error as mentioned below..( I have made sure that the value I >am inserting for the 'domain_id' exists in the ls_domain table.) >please tell me what could be the problem... > >INSERT INTO >ls_user(ls_user,domain_id,user_name,user_flag,user_passwd,user_addr,user >_email,created_by, created_date) > VALUES(1,'Chetan Lavti','y','chetan','116-C,Mayur >Vihar','[EMAIL PROTECTED]','Chetan Lavti','2002-02-07'); > >ERROR 1216: Cannot add a child row: a foreign key constraint fails > >Please, help me for the same... > >Thanks and regards, >Chetan Lavti > --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php