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
https://forums.phpfreaks.com/topic/120662-solved-mysql-and-the-null-entry/
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.