sql查询语句中使用if示例
2017-03-18 21:14
363 查看
1,统计金额大于0
条件:查询严格金额大于0
select sum(if(money>0,money,0)) from tmz_userinfo;
2,示例: hits点击量 如果空的话,就默认为0
select message.id id , message.title title , if(message.'hits' is null , 0 , message.'hits') hits , if(comment.'id' is null , 0 ,count(*)) number from message left join
comment on message.id = comment.id group by message.id;
http://bbs.csdn.net/topics/320175893
条件:查询严格金额大于0
select sum(if(money>0,money,0)) from tmz_userinfo;
2,示例: hits点击量 如果空的话,就默认为0
select message.id id , message.title title , if(message.'hits' is null , 0 , message.'hits') hits , if(comment.'id' is null , 0 ,count(*)) number from message left join
comment on message.id = comment.id group by message.id;
http://bbs.csdn.net/topics/320175893
相关文章推荐
- SQL查询语句精华使用简要----关于连接
- SQL查询语句的使用
- SQL查询语句精华使用简要
- SQL查询语句精华使用简要
- 在ASP中使用SQL语句之2:用WHERE子句设置查询条件
- SQL查询语句精华使用简要
- [转] SQL查询语句使用
- SQL查询语句精华使用简要 [转]
- SQL查询语句精华使用简要
- SQL查询语句使用
- SQL查询语句精华使用简要
- SQL查询语句使用方法参考二
- SQL查询语句使用
- SQL查询语句精华使用简要
- 在ASP中使用SQL语句之6:存储查询
- SQL查询语句使用详解
- 数据库知识—SQL查询语句精华使用简要
- SQL查询语句精华使用简要
- SQL查询语句使用简要
- SQL查询语句精华使用简要