gpt4 book ai didi

MySQL : writing a query where a column is the result of a boolean expression

转载 作者:行者123 更新时间:2023-11-29 02:06:26 27 4
gpt4 key购买 nike

我有一张表,其中有如下列:

deposit_received
paperwork_received
preferred_physician
preferred_physician_phone

我们使用此数据的其中一个 View 涉及显示是否有任何此数据丢失。我可以在 PHP 中简单地进行安排,但我宁愿在 MySQL 中进行(如果我可以在 MySQL 中进行,它会利用框架的按功能排序。

所以基本上,我需要编写一个返回的查询:

col1 | col2 | ... | (deposit_received == true && paperwork_received == true && preferred_physician != null && preferred_physician_phone != null)

我已经查看了一些您可以使用的函数,但我无法理解它。

提前致谢!罗布

最佳答案

你总是可以只写查询:

SELECT col1, col2,
(deposit_received
AND paperwork_received
AND preferred_physician IS NOT NULL
AND preferred_physician_phone IS NOT NULL)
AS Result
FROM tableName

括号是可选的,但它提高了可读性。

关于MySQL : writing a query where a column is the result of a boolean expression,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5149649/

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