gpt4 book ai didi

mysql - 与任何其他 sql 语法结合

转载 作者:太空宇宙 更新时间:2023-11-03 11:44:36 25 4
gpt4 key购买 nike

我想在 sql 语法中将查询与其他查询结合起来,我想用

显示数据
SELECT * 
FROM tx_log
WHERE (tx_command = 'prepaid-response' AND tx_status = 'OK')
OR (tx_command = 'postpaid-response' AND tx_status = 'OK')
OR (tx_command = 'cek-response' AND tx_status = 'NOK')
AND tx_timestamp between '2016-09-19 00:00:01' and '2016-09-20 00:00:01';

上面的语法很明显没有显示错误消息,但显示的数据与指定日期不匹配。在上面,我将显示从 2016-09-19 到 2016-09-20 的数据,但实际显示的日期并非如此。

谢谢。

最佳答案

试试这个

SELECT * 
FROM tx_log
WHERE ((tx_command = 'prepaid-response' AND tx_status = 'OK')
OR (tx_command = 'postpaid-response' AND tx_status = 'OK')
OR (tx_command = 'cek-response' AND tx_status = 'NOK'))
AND tx_timestamp between '2016-09-19 00:00:01' and '2016-09-20 00:00:01';

您错过了外括号 ()。当所有 OR 条件结束时。

关于mysql - 与任何其他 sql 语法结合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39566280/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com