mysql中容易忽略的问题

1. null是不可比较的(跟java中的NaN类似),因此其比较操作总是false比如:

update table set channel = #channel# where order_id = 12345  and channel <> 'AA'  (如果channel为null,则channel<>'AA'也总是不成立的)

2. count distinct的bug:select count(distinct three_part_extend) from table_order where three_part_extend is not null and three_part_extend<>'{}'

具体见:http://dinglin.iteye.com/blog/1976026  http://dinglin.iteye.com/blog/1982176

原文地址:https://www.cnblogs.com/xinglongbing/p/5068897.html