开发者

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'])) {
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜