Mysql, retrieve students who haven't received a request from me [closed]
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
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.
add a comment |
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
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
add a comment |
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
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
mysql database
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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!
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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!
add a comment |
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!
add a comment |
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!
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!
answered Nov 25 '18 at 19:57
digijaydigijay
6041916
6041916
add a comment |
add a comment |
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