mysql and not null column
i have a address field and null is set to no. but when i insert record to table with empty address field , record added to table. and address column is empty. why record a开发者_Go百科dd to table despite address empty?
Could depend on how you add the data, for example if you entered the string as '' its not null, its just empty.
It is possible to insert an empty string into a nullable field.
Insert into myTable (address) Values ('')
will work even if Address is not nullable.
Check if your field is really null.
Select * from myTable where address is null
Null and empty are two different things, you need to validate with php before sending data to database. ie;
if (empty($_POST['address'])) {
}
精彩评论