I have a friend table with two primary columns (uid and fid) and am essentially trying to see if for example if the friend is also friends of the user, so
uid 5 -> fid 6
uid 6 -> fid 5
I had tried to mix and mash SELECT queries to somehow return a deciding result, however cannot seem to find anything. count() will return either one or two columns (two being correct), however PHP's PDO has no good means to find number of selected (not affected) rows without hackish loops.
(SELECT count(uid) FROM friends WHERE uid = 1 AND fid = 2)
UNION ALL -- Or plain union
(SELECT count(uid) FROM friends WHERE uid = 2 AND fid = 1)
This of course still returns one or two rows of 0/1 or 0 or 1
Can you think of a way to return either 1 or 0 in MySQL in the first column? or a better way of writing this functionality in to my program? (I try best to avoid hackish things)