Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有以下查询:
$result = query("SELECT IdUser, followingID FROM following WHERE IdUser = '%d' AND followingID = '%d'", $id, $followingID);
我想知道如果基于 0 和 1 计数的结果是 YES 或 NO,如果关系存在,我将如何返回?
这是一种方法:
select (case when exists (SELECT IdUser, followingID FROM following WHERE IdUser = '%d' AND followingID = '%d' ) then 'YES' else 'NO' end) as YesOrNo , $id, $followingID