Jump to content

[SOLVED] MySQL and the NULL entry


backyard

Recommended Posts

I just want to make sure I understand the NULL column in my database. Is it fair to say if it says No then that means that the entry for that field cannot be null so the cell will be filled with some value even if it's left blank. Also, is there any serious consequences if I change this to NULL? I have a pulldown entry input form and the default choice is blank on the html side even if someone leaves the pulldown in the default position the cell value automatically gets entered with the next value down since it's not null. Also, is there any restrictions on type when you select NULL as the field is currently set to varchar.

 

Thanks

Link to comment
Share on other sites

If the column is NULL then you must add a value into the column when you do your insert.  However, if you have set a DEFAULT value on table creation, then you don't have to add a value on insert as the default value will be used.

 

To insert a NULL value, just leave the column name from the INSERT statement. Columns have NULL as default unless specified by NOT NULL. You can have null values for integers as well as text or binary data.

 

So, you can insert nothing into a NULL field (although if it's not intentional i'd advise you use PHP or whatever language you're sending the commands to MySQL with to check the input's validity before sending the request) without input and you can also check if a field has a NULL value when selecting.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.