SELECT place,username,dt,
IF(dt=last_day('2009-05-01') and (place!='leroy' or place!='starworld'),amount,0)
FROM CasinoRolling where username='888888888'
为什么查出来 dt=last_day('2009-05-01') and place='starworld' 的 amount不显示为0!
解决方案 »
- 在postgresql admin里面写入SQL语句以及建立复合类型问题
- mysql如何对先有表进行分区?
- linux安装最新mysql5.5,my.cnf找不到
- 再问个关于mysql预处理prepare的问题
- 如何让 phpmyadmin 中表的字段显示完全呢?(有些字符串字段内容很多)
- 求一mysql升级的解决方案,在线等!
- 系统突然断电后再重启发现mysql无法自动启动,需要再次正常关机后mysql才能正常起动,请大侠帮忙看看
- 如何创建mysql本地数据库,接着如何部署通过地址链接
- mysql group by请教
- mysql无法从doc环境进入root
- 表a 的 字段id是int where id='1'
- mysql 如何看一个表的索引
(place='leroy'or place='starworld')
place 等于 leroy 或者等于 starworld这个在逻辑上一点问题都没有!(place!='leroy'or place!='starworld')place 不等于 leroy 或者 不等于 starworld
就算place 是任何值,总一个 (place 不等于 leroy ) 或者 (place 不等于 starworld ) 为真!楼主的逻辑没搞清楚,用汉字说明一下你想做的事!估计你是想要
IF(dt=last_day('2009-05-01') and not (place='leroy'or place='starworld'),amount,0)
SELECT place,username,dt,
IF(dt=last_day('2009-05-01') and (place!='leroy' or place!='starworld'),amount,0)
FROM CasinoRolling where username='888888888'我想要的结果是
-------------------------------------------------------------------------------------------------------------------
place | username | dt | IF(dt=last_day('2009-05-01') and (place!='leroy' or place!='starworld'),amount,0)
-------------------------------------------------------------------------------------------------------------------
aaa | 888888888 | 2009-05-31 | 5000
bbb | 888888888 | 2009-05-31 | 2000
leroy | 888888888 | 2009-05-31 | 0 [这个时候条件不满足:place!='leroy' 就给amount显示0]
ccccc | 888888888 | 2009-05-31 | 6000
starworld| 888888888 | 2009-05-31 | 0 [这个时候条件也不满足:place!='leroy' 就给amount显示0]也就是说但时间是2009-05-31的时候,但 place='leroy' or place='starworld' 的话 amount就显示0
这样写可以实现:
IF(substring(from_days(floor(shift/10)+719528),1,10)=last_day('2009-05-01') and place='starworld' or place='leroy',0,amount)
但我现在需要同时判非的实现,这是我简化来的一个小查询.
不知道我说清楚了么?各位高人有没理解我意思的继续问我!