首先,目标记录是存在的
SELECT * FROM d_device_user_bind dub WHERE dub.`uid`='222222222221'
其次,
SELECT dub.uid,dub.`device_id`,IF(IFNULL(dub.`device_id`,2)=2, 2, 1) isActivate FROM d_device_user_bind dub WHERE dub.del_flag=0 ORDER BY dub.`create_time` DESC LIMIT 8;
换一个语句: SELECT dub.uid,dub.`device_id`,IF(dub.`device_id` IS NULL OR dub.`device_id`='', 2, 1) isActivate FROM d_device_user_bind dub WHERE dub.del_flag=0 ORDER BY dub.`create_time` DESC LIMIT 8;
再一个写法: SELECT dub.uid,dub.`device_id`,IF(ISNULL(dub.`device_id`), 2, 1) isActivate FROM d_device_user_bind dub WHERE dub.del_flag=0 ORDER BY dub.`create_time` DESC LIMIT 8;
不知道为什么会这样,也许是mysql的一个bug吧。