0

I have 2 tables with following structures:-

1) Student_Details:-

studentId(pk)
studentName
studentGrade
studentExamStatus

2) Student_Result:-

studentId(fk)
studentRank

The data is inserted in 2nd table only if studentExamStatus is P, otherwise if the studentExamStatus is F there is no record in 2nd table for that student.

I want to write query that will give me all the details of all the students along with rank and if there is no rank blank data or null value is fetched.

I tried with normal join but its only giving me students with rank and not all the students

2 Answers 2

3
SELECT sd.*, sr.StudentRank
FROM Student_Details as SD
LEFT OUTER JOIN Student_Result as SR
    ON sd.StudentID = Sr.StudentID

Any student without a record in Student_Result will return NULL for StudentRank.

Sign up to request clarification or add additional context in comments.

Comments

0

You should have a look at how you can use outer joins.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.