Note that there are some explanatory texts on larger screens.

plurals
  1. POMysql Query Help for Recommended friends
    primarykey
    data
    text
    <p>I have to find friends of friends (not my friends) from an sql table but the problem is that am stuck with excluding users who are already my friends or some blocked friends.</p> <p>Here is the query</p> <pre><code>SELECT IF(Friends.User_Id1 IN (1111,2222), Friends.User_Id2, Friends.User_Id1) AS 'Friend_Id', CONCAT(User_FirstName," ",User_LastName) AS User_FirstName, User_ProfilePic FROM Users JOIN Friends ON IF(Friends.User_Id1 IN (1111,2222), Friends.User_Id2, Friends.User_Id1) = Users.User_Id WHERE (Friends.User_Id2 IN (1111,2222) OR Friends.User_Id1 IN (1111,2222)) AND (Friends.User_Id2 != MY_ID AND Friends.User_Id1 != MY_ID AND Friends.Status = 1) LIMIT 10; </code></pre> <p>In the above case, 1111 and 2222 are my friends and I am trying to get all their friends that is fine but what I want is:</p> <ol> <li>users already my friends who are also friends with either 1111 and 2222 and are shown in the list. I don't want them here because they are in another friends list already.</li> <li>Users I had blocked i.e Friends.Status for MY_ID and friends_friend_id = 3, I am having one in the case too, a user id 3333 is friend of 2222 and I had blocked him already but he is present in the list.</li> </ol> <p>Please guide me if the searching via <code>IN(1111,2222)</code> would lead to some issue in future too because friends count would definitely increase. I have a comma separated list of my friends using <code>group_concat</code> before the above query. All this is in a stored procedure.</p> <p>I hope I explained the problem clearly.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload