求sql语句
时间:2011-11-24
来源:互联网
要筛选的结果要求为
1. a,b,c三列不能都为零 即不能出现(0,0,0)
2. a,b,c三列任一一列或两列为零时的数据条目
3. a,b,c三列都不为零,但如果其中任意一列小于10时,选出此条数据
要求符合以上条件
表名 table
作者: csdweilu 发布时间: 2011-11-24
作者: pengxuan 发布时间: 2011-11-24
select * from tb where a+b+c <> 0 and ((a*b=0 or b*c=0 or a*c=0) or (a*b*c<>0 and (a<10 or b<10 or c<10)))
作者: AcHerat 发布时间: 2011-11-24
作者: fuxiyang 发布时间: 2011-11-24
select * from tb where not (a=0 and b=0 and c=0) and ((a=0 and b=0 or a=0 and c=0 or b=0 and c=0) or (a<>0 and b<>0 and c<>0 and (a<10 or b<10 or c<10)))
作者: qianjin036a 发布时间: 2011-11-24
select * from tb where not (a=0 and b=0 and c=0) and ((a=0 and b=0 or a=0 and c=0 or b=0 and c=0) or (a*b*c<>0 and (a<10 or b<10 or c<10)))
作者: qianjin036a 发布时间: 2011-11-24
SQL code
select * from tb where not (a=0 and b=0 and c=0) and ((a=0 or b=0 or c=0) or (a*b*c<>0 and (a<10 or b<10 or c<10)))
作者: qianjin036a 发布时间: 2011-11-24
SQL code
select * from temptable where (a<10 or b<10 or c<10) and not (a=0 and b=0 and c=0)
作者: csdweilu 发布时间: 2011-11-24
作者: fuxiyang 发布时间: 2011-11-24
都不对,我自己想出来了,其实是考虑的太复杂了
SQL code
select * from temptable where (a<10 or b<10 or c<10) and not (a=0 and b=0 and c=0)
你是要查询至少有一列不为0,并且至少有一列小于10的结果吧?
作者: fuxiyang 发布时间: 2011-11-24
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28