Display full details of students who are in NOT selected for football team ( use LEFT JOIN )
SELECT id,name,class,mark,sex,f_id FROM `student`
LEFT JOIN student_football on id=f_id
WHERE f_id IS NULL
Display full details of students who are selected for football team
SELECT id,name,class,mark,sex,f_id FROM `student`
LEFT JOIN student_football on id=f_id
WHERE f_id is not null
Display full details of students who are in baseball team
SELECT id, name, class, mark, sex, b_id
FROM `student`
LEFT JOIN student_baseball ON id = b_id
WHERE b_id IS NOT NULL
Display full details of students who are not there in football or baseball team SELECT id,name,class,mark,sex,b_id,f_id FROM `student`
LEFT JOIN student_baseball on id=b_id
LEFT JOIN student_football on id=f_id
WHERE b_id is null and f_id is null
Display full details of students who are there in any one team SELECT id,name,class,mark,sex,b_id,f_id FROM `student`
LEFT JOIN student_baseball on id=b_id
LEFT JOIN student_football on id=f_id
WHERE b_id is not null or f_id is not null