开发者

MYSQL include NULL in query

$sql = "SELECT * FROM orders WHERE order_number>=$lower AND order_number<=$upper";

I migrated servers recently and on the previous server this statement included ALL records between $upper and $lower.

The new server excludes the NULL records between $upper and $lower.

Incomplete orders are saved consecuti开发者_StackOverflowvely without order_number(s); and a NULL value.

I assume there is a setting in the MYSQL.conf file. Or I am using a different version of MYSQL that no longer supports automatically including the NULL value in a query.


I have no idea why the old server included null values as that would violate a fundamental rule about how comparison to nulls should work. If you want nulls your query should be something like:

Select ...
From orders
Where ( order_number >= $lower And order_number <= $upper )
    Or order_number Is Null
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜