[英]Storing empty strings vs NULLs in MySQL database?
I have a PHP/MySQL application that stores "blank" values in some cases as ''
(empty strings) and in other cases as NULL
s. 我有一个PHP / MySQL应用程序,在某些情况下将“空白”值存储为
''
(空字符串),在其他情况下存储为NULL
。
Having this mixed format certainly causes a problem when comparing, so I'm wondering which one is the better storage mechanism? 拥有这种混合格式肯定会在比较时出现问题,所以我想知道哪一个是更好的存储机制?
''
or NULL
? ''
还是NULL
?
While this is confusing, actually you should store null for a number of reasons : 虽然这很令人困惑,但实际上你应该存储null有很多原因:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.