draconlock Posted February 8, 2010 Share Posted February 8, 2010 Hi Everyone, I have a problem. So here is my setup. TABLE1 id | firstname ------------------------ 1 | John 2 | Susan 3 | Michael TABLE2 userid | date | payment ------------------------------- 1 | 2009-12-28 | Unpaid 2 | 2010-02-10 | Paid 3 | 2010-02-28 | Unpaid This is my select statement select table1.id, table1.firstname, table2.userid, table2.date, table2.payment from table1 inner join table2 on table2.userid=table1.id where payment='Unpaid' order by table1.id My problem is I want to only select/print the row, where the date is past due and unpaid. Can someone help me figure this out, I can't get it to work and i'm new at this. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/191414-date-selection/ Share on other sites More sharing options...
ignace Posted February 8, 2010 Share Posted February 8, 2010 Is date the due date? SELECT * FROM table1 t1, table2 t2 WHERE t1.id = t2.userid AND t2.payment = 'Unpaid' AND t2.date < now() Quote Link to comment https://forums.phpfreaks.com/topic/191414-date-selection/#findComment-1009087 Share on other sites More sharing options...
greatstar00 Posted February 8, 2010 Share Posted February 8, 2010 wat is the date for, in 2nd table? payment due date? select table1.id, table1.firstname, table2.userid, table2.date, table2.payment from table1 inner join table2 on table2.userid=table1.id where payment='Unpaid' and unix_timestamp(table2.date)>now() order by table1.id now() might not be the correct function, so u need to figure out Quote Link to comment https://forums.phpfreaks.com/topic/191414-date-selection/#findComment-1009089 Share on other sites More sharing options...
draconlock Posted February 8, 2010 Author Share Posted February 8, 2010 Yes the date in table2 is actually the due date. Is date the due date? SELECT * FROM table1 t1, table2 t2 WHERE t1.id = t2.userid AND t2.payment = 'Unpaid' AND t2.date < now() Quote Link to comment https://forums.phpfreaks.com/topic/191414-date-selection/#findComment-1009098 Share on other sites More sharing options...
ignace Posted February 8, 2010 Share Posted February 8, 2010 If it's the due date then my query should work Quote Link to comment https://forums.phpfreaks.com/topic/191414-date-selection/#findComment-1009108 Share on other sites More sharing options...
draconlock Posted February 8, 2010 Author Share Posted February 8, 2010 Its actually printing for some reason. 1 | 2009-12-28 | Unpaid 3 | 2010-02-28 | Unpaid If it's the due date then my query should work Quote Link to comment https://forums.phpfreaks.com/topic/191414-date-selection/#findComment-1009111 Share on other sites More sharing options...
draconlock Posted February 8, 2010 Author Share Posted February 8, 2010 Ok nvm I saw what I did wrong it actually works. Thanks alot guys your the best Quote Link to comment https://forums.phpfreaks.com/topic/191414-date-selection/#findComment-1009114 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.