mysql if函数使用例子
2017-11-17 15:21
387 查看
1.场景一
有时查询数量a 同时查询过滤后的数量b
2. 代码
3. 说明
3.1 可以嵌套
3.2 ifnull(condition, expr1)功能类似 当condition为null 则返回expr1 ,否则返回 condition
有时查询数量a 同时查询过滤后的数量b
2. 代码
SELECT count(id) as total_count, count( IF ( date(order_time) = DATE(now()), 1, NULL ) ) as today_count FROM passenger_activity_record where a = #{a,jdbcType=INTEGER} and b_id= #{bId,jdbcType=INTEGER}
3. 说明
3.1 可以嵌套
3.2 ifnull(condition, expr1)功能类似 当condition为null 则返回expr1 ,否则返回 condition
相关文章推荐
- 使用Jena将本体存入MySQL——文档和例子
- Hibernate4使用映射文件hbm.cml连接访问MySQL的小例子
- mysql的查询sql中使用case的例子
- mysql + unidac 使用事务例子
- jdbc链接mysql的第二个例子。使用properties文件存放连接信息。使用jar文件一个
- mysql + unidac 使用事务例子
- MySQL 5.0 存储过程例子(使用了游标)
- MYSQL中有关SUM字段按条件统计使用IF函数(case)问题
- MySQL 如何使用索引 较为详细的分析和例子
- java使用jdbc查询mysql数据最简单的例子
- MySql中使用INSERT INTO语句更新多条数据的例子
- Hibernate4使用Annotation连接访问MySQL的小例子
- mysql + unidac 使用事务例子
- MYSQL中SUM字段按条件统计使用IF函数(case)
- mysql + unidac 使用事务例子
- MySQL 如何使用索引 较为详细的分析和例子
- [待总结]mysql配置、使用例子
- MYSQL中有关SUM字段按条件统计使用IF函数(case)问题
- Windows下 使用 MySQL的参考例子
- MySQL取第一条数据方法:SQL语句分组的方法,使用Northwind 数据库为例子。