mysql - 如何在 MySQL 服务器的“where”中使用案例
问题描述
我收到一个错误,
表达式在 case 内的条件下无效。
运行 MySQL 时:
WHERE
CASE
WHEN TBL1.Reissued<>'1'
THEN
fare IS NOT NULL
AND
fare <> 0.00
END
WHERE
fare IS NOT NULL
AND
fare <> 0.00
解决方案
首先,fare IS NOT NULL AND fare <> 0.00
可以简化为fare <> 0.00
,因为任何条件都会消除NULL
,因为每个与NULL
value 的比较unknown
都会被认为是错误的。
现在,您可以使用这样的条件:
where (TBL1.Reissued<>'1' and fare <> 0.00) or TBL1.Reissued='1'
推荐阅读
- java - 使用 mybatis 调用传递整数数组的 Postgresql 函数
- javascript - React 如何在弹出窗口中显示单个数据
- python - 为什么'exec'在函数内部表现不同?
- file-permissions - Google Docs 时间驱动的文件权限更改
- java - 如何在使用 JSP/JSTL 的同时配置我的表达式语言以在 eclipse 中工作?只是JSP?
- c++ - 从原始指针返回智能指针
- android - 如何连接BLE设备并发送MTU请求并通过Service UUID逐步获取服务的特征UUID
- python - 将列表编入字典
- c++ - 编译 Arduino 代码(NodeMCU)时出错
- python - 发出请求时出现 Azure 表单识别器错误属性错误