搞不明白的查询! 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读语句优化一些好的习惯----yueliangdao0608 一个关于记录分组的问题 这样创建数据表有问题嘛? 我对MySQL的C API觉得莫名奇妙的的一点,关于MYSQL_ROW 请问怎么样些查询语句方便一点. access 导入 mysql 乱码 求救!! mysqlbinlog问题 在MYSQL里,Lock Tables 与Unlock Tables怎么使用?!(举例) MySQL创建表错误 紧急求助 表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)
但我现在需要同时判非的实现,这是我简化来的一个小查询.
不知道我说清楚了么?各位高人有没理解我意思的继续问我!