How to list all pending friend requests for a given user ID?
how to list all pending requests to uid X? I tried this (X=132)


SELECT GREATEST(uid1, uid2), LEAST(uid1, uid2)
FROM tbl_friendship 
WHERE 132 IN (uid1, uid2)
GROUP BY 1, 2
HAVING COUNT(*) = 1



  I'm only interested to find everyone who send friend request to 132. – anta40


SELECT t1.uid2
FROM tbl_friendship t1
WHERE t1.uid2 = 132
  AND NOT EXISTS ( SELECT NULL
                   FROM tbl_friendship t2
                   WHERE (t1.uid1, t1.uid2) = (t2.uid2, t2.uid1) );