how to get the people i follow but they don't follow me back ???

  • i have table called follows_sys  with three columns id and follower  and following aand i want to get all people i follow but only those who don't follow me back

  • marwanyadri8 - Sunday, July 1, 2018 6:48 PM

    i have table called follows_sys  with three columns id and follower  and following aand i want to get all people i follow but only those who don't follow me back

    That has to be a homework question and we aren't big on answering other people's homework unless we can see what you've already attempted.
    But I'll give a (very large) hint - in that table, what signifies that you are being followed and what signifies that you are following?

    Post what you believe your solution might be and people will be happy to help and explain. Just ask for an answer and we will get nowhere.

  • So basically the followers column stores me when j follow someone and the following stores the user that I'm following him but when he follows back it is the opposite i tried to self join the table to itself
    But instead of getting the people that i follow but they didn't follow me back it gets everyone so i want to get only the column the contains the following people and I'm the follower but not the them followers and not me follower
    So i did something like this

    "SELECT * FROM follow_sys t1, follow_sys t2 where
    t1.follower != $follower
    And 
    t2.following != $me_followed 
    I don't know how to get only the rows that don't co contains me as followed

  • marwanyadri8 - Monday, July 2, 2018 1:09 AM

    So basically the followers column stores me when j follow someone and the following stores the user that I'm following him but when he follows back it is the opposite

    OK, so in that one sentence you've already told me more than I knew earlier.
    I assumed that the table was an ID column and then simply two 'flags', because you didn't supply enough detail.
    This is an important lesson - when asking for assistance you must supply enough detailed information to show what your issue is  -without any chance that you will be misunderstood. Believe me, it is very annoying spending a lot of personal time trying to help somebody, only to find that you have completely misunderstood the problem.

    So....

    Have a look at this article first, which explains how to post code that will help other people understand your issue. It might seem to be a lot of work for what will be a simple solution but it also helps you to think through the problem.
    I have written a lot of questions on this site that I have never posted, because when I have created the example it has helped me to find the solution myself. Writing it down to explain the other people can really help - you and the other people.
    It also helps people like me to help you quickly. I'm working right now, so can't spend a lot of time looking at your problem - so help me by providing the data I need to see exactly why you're stuck, without having to create my own test data.
    There are a lot of very helpful people in this forum but they're also very busy. Anything you can do to help them to help you will be appreciated - and get you nmore help in the future.

  • Have you tried using EXCEPT?

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • Luis Cazares - Monday, July 2, 2018 6:29 AM

    Have you tried using EXCEPT?

    That would be my recommendation, as well.  WHERE NOT EXISTS might also do it.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • I hope this isn't a homework project, otherwise, I'd have to ask What are they teaching them, deprecated syntax?

    For better, quicker answers, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply