Mysql, retrieve students who haven't received a request from me [closed]












0















I am currently logged in as the first student. I want to retrieve a list of the students I did not send a request to yet. I also want to retrieve a list of students I sent a request to.



Both sender_id and Rec_id are foreign keys referencing to Students.id.



DB schema










share|improve this question













closed as too broad by Madhur Bhaiya, Barmar, Bohemian Nov 25 '18 at 20:05


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.














  • 1





    Welcome to Stack Overflow! StackOverflow is not a free coding service. SO expects you to try to solve your own problem first. Please update your question to show what you have already tried in a Minimal, Complete, and Verifiable example. For further information, please see How to Ask, and take the tour :)

    – Barmar
    Nov 25 '18 at 19:24
















0















I am currently logged in as the first student. I want to retrieve a list of the students I did not send a request to yet. I also want to retrieve a list of students I sent a request to.



Both sender_id and Rec_id are foreign keys referencing to Students.id.



DB schema










share|improve this question













closed as too broad by Madhur Bhaiya, Barmar, Bohemian Nov 25 '18 at 20:05


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.














  • 1





    Welcome to Stack Overflow! StackOverflow is not a free coding service. SO expects you to try to solve your own problem first. Please update your question to show what you have already tried in a Minimal, Complete, and Verifiable example. For further information, please see How to Ask, and take the tour :)

    – Barmar
    Nov 25 '18 at 19:24














0












0








0








I am currently logged in as the first student. I want to retrieve a list of the students I did not send a request to yet. I also want to retrieve a list of students I sent a request to.



Both sender_id and Rec_id are foreign keys referencing to Students.id.



DB schema










share|improve this question














I am currently logged in as the first student. I want to retrieve a list of the students I did not send a request to yet. I also want to retrieve a list of students I sent a request to.



Both sender_id and Rec_id are foreign keys referencing to Students.id.



DB schema







mysql database






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 25 '18 at 18:45









Souleiman FadalSouleiman Fadal

62




62




closed as too broad by Madhur Bhaiya, Barmar, Bohemian Nov 25 '18 at 20:05


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.









closed as too broad by Madhur Bhaiya, Barmar, Bohemian Nov 25 '18 at 20:05


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 1





    Welcome to Stack Overflow! StackOverflow is not a free coding service. SO expects you to try to solve your own problem first. Please update your question to show what you have already tried in a Minimal, Complete, and Verifiable example. For further information, please see How to Ask, and take the tour :)

    – Barmar
    Nov 25 '18 at 19:24














  • 1





    Welcome to Stack Overflow! StackOverflow is not a free coding service. SO expects you to try to solve your own problem first. Please update your question to show what you have already tried in a Minimal, Complete, and Verifiable example. For further information, please see How to Ask, and take the tour :)

    – Barmar
    Nov 25 '18 at 19:24








1




1





Welcome to Stack Overflow! StackOverflow is not a free coding service. SO expects you to try to solve your own problem first. Please update your question to show what you have already tried in a Minimal, Complete, and Verifiable example. For further information, please see How to Ask, and take the tour :)

– Barmar
Nov 25 '18 at 19:24





Welcome to Stack Overflow! StackOverflow is not a free coding service. SO expects you to try to solve your own problem first. Please update your question to show what you have already tried in a Minimal, Complete, and Verifiable example. For further information, please see How to Ask, and take the tour :)

– Barmar
Nov 25 '18 at 19:24












1 Answer
1






active

oldest

votes


















1














Hi Souleiman and welcome to stackoverflow! Your question is not quite clear, you say that sender_id and Rec_id in requestts are both referencing to students, but you can't see to which field exactly. Your requestts table contains different entries in these fields.



Next time you should post the output of SHOW CREATE TABLE students and SHOW CREATE TABLE requestts and a little INSERT statement for the data. Furthermore it would be nice if you would explain the relations and show what you have already tried (see Barmars comment).



I suppose that the relevant foreign key in requestts is Rec_id, so you could try this query:



SELECT s.email FROM students s WHERE s.id NOT IN
(SELECT Rec_id FROM requestts WHERE Rec_id = s.id);


Hope this helps. Have fun learning SQL!






share|improve this answer






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Hi Souleiman and welcome to stackoverflow! Your question is not quite clear, you say that sender_id and Rec_id in requestts are both referencing to students, but you can't see to which field exactly. Your requestts table contains different entries in these fields.



    Next time you should post the output of SHOW CREATE TABLE students and SHOW CREATE TABLE requestts and a little INSERT statement for the data. Furthermore it would be nice if you would explain the relations and show what you have already tried (see Barmars comment).



    I suppose that the relevant foreign key in requestts is Rec_id, so you could try this query:



    SELECT s.email FROM students s WHERE s.id NOT IN
    (SELECT Rec_id FROM requestts WHERE Rec_id = s.id);


    Hope this helps. Have fun learning SQL!






    share|improve this answer




























      1














      Hi Souleiman and welcome to stackoverflow! Your question is not quite clear, you say that sender_id and Rec_id in requestts are both referencing to students, but you can't see to which field exactly. Your requestts table contains different entries in these fields.



      Next time you should post the output of SHOW CREATE TABLE students and SHOW CREATE TABLE requestts and a little INSERT statement for the data. Furthermore it would be nice if you would explain the relations and show what you have already tried (see Barmars comment).



      I suppose that the relevant foreign key in requestts is Rec_id, so you could try this query:



      SELECT s.email FROM students s WHERE s.id NOT IN
      (SELECT Rec_id FROM requestts WHERE Rec_id = s.id);


      Hope this helps. Have fun learning SQL!






      share|improve this answer


























        1












        1








        1







        Hi Souleiman and welcome to stackoverflow! Your question is not quite clear, you say that sender_id and Rec_id in requestts are both referencing to students, but you can't see to which field exactly. Your requestts table contains different entries in these fields.



        Next time you should post the output of SHOW CREATE TABLE students and SHOW CREATE TABLE requestts and a little INSERT statement for the data. Furthermore it would be nice if you would explain the relations and show what you have already tried (see Barmars comment).



        I suppose that the relevant foreign key in requestts is Rec_id, so you could try this query:



        SELECT s.email FROM students s WHERE s.id NOT IN
        (SELECT Rec_id FROM requestts WHERE Rec_id = s.id);


        Hope this helps. Have fun learning SQL!






        share|improve this answer













        Hi Souleiman and welcome to stackoverflow! Your question is not quite clear, you say that sender_id and Rec_id in requestts are both referencing to students, but you can't see to which field exactly. Your requestts table contains different entries in these fields.



        Next time you should post the output of SHOW CREATE TABLE students and SHOW CREATE TABLE requestts and a little INSERT statement for the data. Furthermore it would be nice if you would explain the relations and show what you have already tried (see Barmars comment).



        I suppose that the relevant foreign key in requestts is Rec_id, so you could try this query:



        SELECT s.email FROM students s WHERE s.id NOT IN
        (SELECT Rec_id FROM requestts WHERE Rec_id = s.id);


        Hope this helps. Have fun learning SQL!







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 25 '18 at 19:57









        digijaydigijay

        6041916




        6041916

















            Popular posts from this blog

            Wiesbaden

            Marschland

            Dieringhausen