lunac Posted November 18, 2007 Share Posted November 18, 2007 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 Quote Link to comment Share on other sites More sharing options...
lunac Posted November 18, 2007 Author Share Posted November 18, 2007 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 />"; } } Quote Link to comment Share on other sites More sharing options...
Barand Posted November 19, 2007 Share Posted November 19, 2007 or $sql = "SELECT dir.fname, dir.lname FROM directory dir LEFT JOIN dues du ON dir.directory_id = du.directory_id AND du.year = YEAR(NOW()) WHERE du.directory_id IS NULL"; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.