In MySql, You can use the SUM()
function over a condition, since a false condition will equal to 0
, and a true one will equal to 1
:
SELECT SUM(userID_follower = $myID) AS followerCount,
SUM(userID_following = $myID) AS followingCount
FROM t1
WHERE userID_follower = $myID
OR userID_following = $myID
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…