IT追梦者

Programming
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

mysql中容易忽略的问题

Posted on 2015-12-23 09:31  星龙冰  阅读(162)  评论(0编辑  收藏  举报

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