sanjay_zed Posted December 9, 2011 Share Posted December 9, 2011 i hav some prob while fetching the records. i hav three tables namely jewellers, gs_customer_registration,gs_deposits_trans For one jeweller , he is having ' n' no of customers, dat customer is depositing money each month (this record is storing in table customerdeposit) . Now my query is --I need to fetch the customer name which is not paid for current month. while doing am able to do, but is displaying all the months except the current month. $jid=$_SESSION["user_id"]; $current_month= date("m"); $sql="SELECT * FROM gs_customer_registration where jew_id='$jid'"; $result=mysql_query($sql); $rec=mysql_fetch_assoc($result); $a=$rec['customer_id']; $sql1="select * from gs_customer_registration,gs_deposits_trans where gs_deposits_trans.customer_id='$a' "; $sql2="select * from gs_customer_registration,gs_deposits_trans where gs_deposits_trans.customer_id='$a' and gs_deposits_trans.deposited_date not like '%-$current_month-%'"; Quote Link to comment Share on other sites More sharing options...
trq Posted December 9, 2011 Share Posted December 9, 2011 http://www.phpfreaks.com/tutorial/data-joins-unions Quote Link to comment Share on other sites More sharing options...
sanjay_zed Posted December 9, 2011 Author Share Posted December 9, 2011 i tried using join also . but while checking condition am failing to do. Quote Link to comment Share on other sites More sharing options...
trq Posted December 9, 2011 Share Posted December 9, 2011 Then post some relevant code. Quote Link to comment Share on other sites More sharing options...
fenway Posted December 9, 2011 Share Posted December 9, 2011 Or tell us what you think "not working" means. Quote Link to comment Share on other sites More sharing options...
sanjay_zed Posted December 12, 2011 Author Share Posted December 12, 2011 $sql2="select * from gs_customer_registration,gs_deposits_trans where gs_deposits_trans.customer_id='$a' and gs_deposits_trans.deposited_date not like '%-$current_month-%'"; it is displaying all the month except the current month.. I want the customer name who hav not deposited in this current month. i am not getting the proper condition to check on it. Quote Link to comment Share on other sites More sharing options...
fenway Posted December 12, 2011 Share Posted December 12, 2011 Then you need a LEFT JOIN .. IS NULL on that condition. 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.