Jump to content

Remove items from query based on another table


lunac

Recommended Posts

Ok, here's an odd situation that I just can't figure out.

 

I have to tables. A directory table and a dues table. The dues table contains a payment for any member that has paid with the id of their associated record in the directory tables. IE. payment 2007 for id 2 -- id 2 is Bob.

 

If I do a join function I can easily find all the members that have paid for the year.

 

NOW....

how do I find the members that haven't paid? I know it's something like if the id doesn't exist in dues then show it as a record from directory. But how dow I do that exactly?

 

tables:

 

dues --> dues_id, directory_id, amount, year, check_num

directory --> directory_id, fname, lname

 

 

 

Link to comment
Share on other sites

Ok....

 

I figured it out, but here's the answer for anyone else getting stuck on this issue

 

------- please not mysqlSelect is a custom function for rewiting a query statement ----------------


$a = mysqlSelect($_tables['directory']);

while($k = mysql_fetch_assoc($a)){
		// check members dues 
		$z = mysqlSelect($_tables['member_dues'], "dues_id", "WHERE directory_id = " . $k['directory_id']);
		$count = mysql_num_rows($z);
		if($count == 0){
			echo $x . $k['lname'] . "<br />";

                  }
}

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.