mysql IF-IFNULL和IF-ISNULL同样逻辑的运行差别
2024-09-03 12:53:01
首先,目标记录是存在的
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吧。
最新文章
- 转移博客到xinqiyang.freeflare.com了,这里会继续更新.
- Linux umount设备时出现device is busy解决方法
- This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes. This will cause an exception in a future release.
- javascript垃圾回收机制
- Linux下软件包的多种安装方式
- html_
- python 安装scrapy
- HDU 4539 郑厂长系列故事——排兵布阵
- SQLSERVER数据库管理数据库原理
- 三菱plc输出指示灯不亮怎么办(转载)
- Unity Flow distort of screen
- js获取当前url地址及参数
- JQ对JSON的增删改
- undefined与null
- CentOS 引导 Win10 启动项
- python中的异常
- Python基础(生成器)
- QIDO-RS - Search
- centos linux查看硬盘型号
- HTML5实现全屏API【进入和退出全屏】
热门文章
- 执行SQL时出现: ORDER BY clause is not in GROUP BY clause and contains nonaggregated c
- 5(计算机网络)从物理层到MAC层
- 为常用的块类型创建typedef
- 二十 Spring的事务管理及其API&;事务的传播行为,编程式&;声明式(xml式&;注解式,底层AOP),转账案例
- 【剑指Offer面试编程题】题目1522:包含min函数的栈--九度OJ
- zabbix开启对中文的支持--&;&;--中文乱码解决方法
- java并发之Future与Callable使用
- input文件类型上传,或者作为参数拼接的时候注意的问题!
- Day10 - C - Blow up the city HDU - 6604
- 1-3SpringBoot之Controller使用