Results 1 to 5 of 5
Thread: Foreign Key Issue
Jan 7, 2010, 21:53 #1
- Join Date
- Jun 2005
- 0 Post(s)
- 0 Thread(s)
Foreign Key Issue
I've got a table that contains a FK for lookups.
These are INT(10) unsigned, nullable because they won't always have a valid entry.
When I try and update a row I get a "Database query failed: Cannot add or update a child row: a foreign key constraint fails".
The statement looks like this "UPDATE table SET id='1', idOfFK='', next field".
The idOfFK has 2 single quotes or NULL, right.
The object that's building the UPDATE statement is being passed a value of NULL. How can I get the word NULL in a string. It seems that I can get '' or 'NULL' but not just NULL.
I'm also not sure why there's a constraint issued with the nullable field either, the field will sometimes not be there. How could I get a NULL entry in the auto_increment PK field; that doesn't make sense.
I hope I haven't confused you as much as I am confused :-)
Any thoughts would be appreciated.