我有以下查询:
$result = query("SELECT IdUser, followingID FROM following WHERE IdUser = '%d' AND followingID = '%d'", $id, $followingID);
我想知道如果结果是YES,我将如何返回,如果关系存在,我将如何根据0和1计数返回?
答案 0 :(得分:1)
这是一种方式:
select (case when exists (SELECT IdUser, followingID
FROM following
WHERE IdUser = '%d' AND followingID = '%d'
)
then 'YES' else 'NO'
end) as YesOrNo
, $id, $followingID