gpt4 book ai didi

php - 是否可以在 SQL 中使用 if 语句?

转载 作者:行者123 更新时间:2023-11-29 04:42:16 28 4
gpt4 key购买 nike

所以基本上我有一个数据库,用于保存电子邮件事件的排队电子邮件。

电子邮件可以有一堆不同的状态,如果电子邮件失败,他们会重新尝试。

表格看起来像

id       email              status      attempts0       test@test.com       failed         40       test@test.com       success        20       test@test.com       success        10       test@test.com       failed         20       test@test.com       new            0

我想统计到目前为止已发送或尝试次数过多的所有电子邮件。

换句话说,计算状态为"new"的所有电子邮件,但如果状态为“失败”,则只计算尝试次数为 4 或更高的邮件。

这可以通过 SQL 查询实现,还是我必须在 PHP 中执行?

提前致谢!

最佳答案

你可以写

WHERE status = 'success'
OR status = 'failed' AND attempts >= 4

关于php - 是否可以在 SQL 中使用 if 语句?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25897428/

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