That's what it was... I was doing this in a test database and forgot that I changed some values manually before. Thanks,
Sergei -----Original Message----- From: Ady Wicaksono [mailto:[EMAIL PROTECTED] Sent: Friday, February 18, 2005 10:55 PM To: Sergei Skarupo Subject: Re: cannot add a foreign key When you alter table like that please make sure that existing table data on signal_segments column db_test_id is valid data For example if table signal_segments containts row (db_test_id) 1 2 3 4 5 then on sensortest_description (db_test_id) contains rows 1 2 3 you found that 4 & 5 is invalid data since on reference table only exist 1,2, and 3 you have to fix it :) Sergei Skarupo wrote: >Hello everyone, > >I'm trying to add some foreign keys to the database... It works fine for one >table but not for another. I need to make them both children of a third table. > >I'm using mysqld-max 4.0.16 on RedHat Linux. > >This is the statement that I ran: > >alter table signal_segments >add foreign key fk_signal_segments1 (db_test_id) >references sensortest_description (db_test_id) >on delete cascade >on update cascade; > > > >And this is the error message: > >Error Code : 1216 > >Cannot add or update a child row: a foreign key constraint fails > >Again, it works fine for another table with a similar structure... > >What could be the reason? > > > >Thanks in advance, > >Sergei > > > > -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]