搞不明白的查询! 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! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 (place!='leroy'or place!='starworld')这是个逻辑错误,恒为 true ! (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 | 6000starworld| 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)但我现在需要同时判非的实现,这是我简化来的一个小查询.不知道我说清楚了么?各位高人有没理解我意思的继续问我! 自己明白了,不是用or,是用and!脑袋短路..............,谢谢各位! MYSQL占用CPU很高?请教配置 linux下修改mysql连接 如何用一句MYSQL语句完成以下任务? 如何能知道存储过程中捕获的是什么异常? 求助 数据库语句如何写? mysql 外键关联 命令行下输入中文的问题 LINUX下能够用脚本实现不登陆mysql数据库来进行查询操作吗? 我用redhat8自带的postgresql,现在要写一个测试程序,怎么写? 主从表、外键、1452 表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)
但我现在需要同时判非的实现,这是我简化来的一个小查询.
不知道我说清楚了么?各位高人有没理解我意思的继续问我!