Click here to Skip to main content
15,885,032 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have two tables, Students and Fees. Students table contains Student Related Data and Fees table contains Fee record of Students.

Actually, My problem is i want to show defaulter students who have not paid this month fee.

Sol. seems to me is :
I want to search all Students first from Students table, then query should search in Fee table for students who have not paid their fee of this month of Current Year..\

My Question is How to write query for my above requirement.
Posted
Updated 6-Feb-13 22:10pm
v2
Comments
bbirajdar 7-Feb-13 4:10am    
You can use Sql Server Management Studio to write the query..Also NotePad++ will be a good editor

There are many ways you could do this. One way could be to retrieve the data from both tables into structures in your code, then you could iterate through them looking for instances where you have a value in your student class but no corresponding entry in the fee class. You could do this, but I wouldn't recommend it.

Another way to do this would be to use the features of SQL and perform a select that looked at both tables simultaneously, possibly joining them together somehow; taking into account that what you are looking for wouldn't be present, so your joining will need to take this into account - possibly giving preference to the table at the left or right hand side of the joining.
 
Share this answer
 
Comments
Harpreet_125 7-Feb-13 4:29am    
can you please tell me how to do this practically..
Pete O'Hanlon 7-Feb-13 4:39am    
I already have - the keywords you need are highlighted in there. I'm not doing your homework for you - 2 minutes with Google using those keywords will tell you everything you need to know.
__TR__ 7-Feb-13 4:49am    
I would recommend you to refer the below links to learn SQL. Then go through the above solution given by Pete. That should give you an idea on how to approach your problem.
SQL Tutorial[^]
SQLCourse.com[^]
Pete O'Hanlon 7-Feb-13 4:58am    
I wish you'd added that as a solution so I could 5 it.
__TR__ 7-Feb-13 6:01am    
I posted the comment as a solution as per your suggestion (not for the upvote), but ended up getting around 500 rep points for that. Went to Site Bugs / Suggestions forum to report it and already found a bunch of messages explaining the same issue. I hope this issue gets fixed soon.
I would recommend you to refer the below links to learn SQL. Then go through the above solution given by Pete. That should give you an idea on how to approach your problem.
SQL Tutorial[^]
SQLCourse.com[^]

You can find more resources on SQL in Google[^] or you can refer to beginner articles on SQL in CP here[^]
 
Share this answer
 
Comments
Pete O'Hanlon 7-Feb-13 6:11am    
My 5.
__TR__ 7-Feb-13 6:50am    
Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900