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の場合、どのように返すのだろうかと思っていましたか?
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