mysql - I cannot add 'null' in foreign key -
I have created two tables as shown below: When I add a null d Value for id_leiame on Unlod, the following error: can not add or update a child row: (let ( `id_leiame`) Sndrb`` leiame` bd`.`download `Badha` foreign key Leia_id_fk` (` Id`) update on CASCADE) fails in a foreign key constraint I have set as NULL to id_leiame. What am I missing? Based on the statements stated in the other comments, depending on the statement you are performing, you will be able to ' Null '(ie). Instead of the actual tap, i.e. zero for a string containing the value of the value). What you should do ( not the proper syntax) is something on the line >
create tables `leiame` (` id` INT (10) unsigned nOT NULL AUTO_INCREMENT, `number` INT (10) nOT NULL,` title` VARCHAR (100) nOT NULL, pRIMARY KEY ( `id`)) CREATE TABLE` download` ( `id` INT (10) nOT nULL AUTO_INCREMENT,` name` VARCHAR (100) nOT nULL, `id_leiame` INT (10) unsigned zero, pRIMARY KEY (` Id`), Badha` foreign key leia_id_fk` ( `id_leiame`) Give reference `leiame` (` id`) updated CASCADE oN)
if ($ leiame == "" ) $ Crud- & gt; Inserir ("name, id_leiame", "'$ name', null") & lt; & Lt; No single quote! The rest $ crud- & gt; Inserir ("name, id_leiame", "'name', '$ leiame'")
Comments
Post a Comment