gpt4 book ai didi

php - 返回是或否 PHP 查询

转载 作者:行者123 更新时间:2023-11-29 13:40:56 24 4
gpt4 key购买 nike

我有以下查询:

    $result = query("SELECT IdUser, followingID FROM following WHERE IdUser = '%d' AND followingID = '%d'", $id, $followingID);

我想知道如果关系存在的话,如果根据 0 和 1 计数结果为"is"或“否”,我将如何返回?

最佳答案

这是一种方法:

select (case when exists (SELECT IdUser, followingID
FROM following
WHERE IdUser = '%d' AND followingID = '%d'
)
then 'YES' else 'NO'
end) as YesOrNo
, $id, $followingID

关于php - 返回是或否 PHP 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18093538/

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