To avoid "duplicate" rows.. e.g. 2 rows for every couple of friends, add the condition a. Uid.
SELECT a. Uid, a. Fid FROM friends a JOIN friends be ON a.
Fid = b. Uid AND a. Uid = b.
Fid WHERE a. Uid = 1 AND a. Fid = 2 To avoid "duplicate" rows.. e.g.2 rows for every couple of friends, add the condition a.
Uid Uid, a. Fid FROM friends a JOIN friends be ON a. Fid = b.
Uid AND a. Uid = b. Fid AND a.
Uid Fid = 2 So, to count all friendships, use: SELECT COUNT(*) AS countAllFrienships FROM friends a JOIN friends be ON a. Fid = b. Uid AND a.
Uid = b. Fid AND a. Uid Uid So, to count friends of user X, use: SELECT a.
Uid , COUNT(*) AS numberOfFriends FROM friends a JOIN friends be ON a. Fid = b. Uid AND a.
Uid = b. Fid WHERE a. Uid = X GROUP BY a.uid.
Thank you for these examples, I enjoy picking at them to learn. – Den R. Jun 30 '11 at 10:45.
You need an auto join to return all the couple user/friend which are in a bijection friendship : SELECT f. Uid, f. Fid FROM Friend f INNER JOIN Friend ff ON f.
Uid = ff. Fid AND f. Fid = ff.
Uid Be aware that it will return 'duplicates', in you case : uid | fid 5 6 6 5.
Select count(*) from friends where ((uid = 1) and (fid = 2)) or ((uid = 2) and (fid = 1)) Note that you have to do a count(*), as the UID's will be different if there's a mutual friendship. You'd get two rows with a count of 1, instaed of a single row with a count of 2.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.