here still got lots to learn thanks for the help in advance. *bows tried several time cant seems to get it to work hope to get some help from more experienced coders
I want to show staff that are not teaching anyone
enter image description here original table
Staff_ID Mentor_ID First_Name Last_Name
----------- ----------- ------------------------- -------------------------
101 NULL May Ou
102 101 Io Rush
103 102 Ley Have
104 103 Stephanie Soon
105 101 Iat Raiz
106 101 Rina shion
--notes
- not having a mentor id they are not learning from anyone
- having a mentor id learning that that person e,g 102 staff "Io Rush" is learning from staff 101 "May Ou" therefore means staff 101 is teaching 102 as well.
- therefore if staff id of a staff did not appear in mentor id they are not teaching anyone e.g. staff 104, 105 & 106
--basic key points
- staff 101 is not learning from any one but is teaching other people
- staff 102,103,104,105,106 are all learning from someone
- staff 101,102,103 are the only staff that are teaching other staff
- staff 104,105,106 are the only ones not teaching anyone
--my codings:
SELECT *
FROM staff
WHERE Staff_ID IN (SELECT Mentor_ID FROM staff)
--Result enter image description here
Staff_ID Mentor_ID First_Name Last_Name
----------- ----------- ------------------------- -------------------------
101 NULL May Ou
102 101 Io Rush
103 102 Ley Have
-- this show the complete opposite of what i am going for as this show all staff that is teaching someone
-- so i tought of an idea an since its the opposite should be just adding a NOT will give me what i one so i type the following code
--coding 2 :
SELECT *
FROM staff
WHERE Staff_ID NOT IN (SELECT Mentor_ID FROM staff)
--result: blank....
no idea what else i can do --" kinda stuck now, btw i am still a newbie to mysql so there may be i function of stuff that i dont know of please bear with me*bows yup so that is a detailed description of my problem, i thank all those in advance for taking your time to read my problem all advice is appreciated, hope to hear from you guys soon *waves waves :D