Jump to content


Photo

display student name that is not present in tbl_studentFees


  • Please log in to reply
1 reply to this topic

#1 TheJuan

TheJuan
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 07 June 2006 - 03:23 AM

hi

i just wondering how can it be possible to make a query of this situation.
I have a list of student name in tbl_students and a table tbl_payments where stored a list of students(id,name,amount) who already pay for a fee.

i want to display those all name of students that are in tbl_students but not yet in tbl_payments

something like:
select id,name from tbl_student where id is not present in tbl_payments

thanks

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 09 June 2006 - 05:52 AM

This calls for a LEFT JOIN (UNTESTED):

SELECT s.id, s.name 
FROM tbl_student AS s 
LEFT JOIN tbl_payments AS p ON s.id = p.student_id
WHERE p.student_id IS NULL

Hope that helps.

Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users