fees tableemployee tablethere are two sql tables student and fees both are having student id column ..in student table department id and in fees table department name need to fetch students details who didn't pay fees means if student did't pay fees then his record should be displayed based on student table having dept id and fees table dept name.
Asked
Active
Viewed 321 times
-1
-
2It's hard to understand what you want. Please post an example structure of your tables and your desired output. – crimson589 Dec 14 '17 at 06:02
-
1Please provide your code here. – Ekta Dushanj Dec 14 '17 at 06:02
1 Answers
2
you have to make use of left outer join , check for the null , you will get all student not paid fees as there entries not paresent in fees table
SELECT *
FROM Student
LEFT JOIN fees ON student.Id = fees.StudentID
where fees.StudentID is null;
//intead of * you have to replace columns you want
// for your question text i think ID in student is primary key and StudentId
// in fees is foreign key so my answer is based on that only
you can also check my answer here : What's the difference between INNER JOIN, LEFT JOIN, RIGHT JOIN and FULL JOIN? for understanding joins
Table structure should be as below

Pranay Rana
- 175,020
- 35
- 237
- 263
-
output is correct need to check dept id from student table and dept name from fees table that will return student id who didn't pay there fees based on department – Nitesh Dundyar Dec 14 '17 at 06:15
-
@NiteshDundyar - please provide your table stucture in detail ...then can able to help in detail..put structure in you question text – Pranay Rana Dec 14 '17 at 06:16
-
@NiteshDundyar - is there any case that one student is related to multiple depart ment ...if not then you table structure is wrong ..you need to modify it ...you need to related student id of student table with studenid of fess table ...department is all to gether diffrent entity – Pranay Rana Dec 14 '17 at 06:18