Is it possible to count two columns in the same query

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

Leave a Comment