Xtremer360 Posted April 18, 2011 Share Posted April 18, 2011 $query = "SELECT * FROM `top5` WHERE `lastUpdated` = ?"; What I'm trying to do is check it again the lastUpdated table and make sure there isn't a row with the same date AND MONTH as an already existing row. Any ideas how to accomplish this. And yes I have lastUpdated as a date field type. Quote Link to comment https://forums.phpfreaks.com/topic/234092-difficult-where-clause/ Share on other sites More sharing options...
Xtremer360 Posted April 18, 2011 Author Share Posted April 18, 2011 A friend told me I should mention that the intention is to see if one of the rows has its month AND year matching the current month and Year. Quote Link to comment https://forums.phpfreaks.com/topic/234092-difficult-where-clause/#findComment-1203190 Share on other sites More sharing options...
mike12255 Posted April 18, 2011 Share Posted April 18, 2011 so you basically want to select all of the information from the record where the lastupdated field equals the same date as the current day? Quote Link to comment https://forums.phpfreaks.com/topic/234092-difficult-where-clause/#findComment-1203194 Share on other sites More sharing options...
mike12255 Posted April 18, 2011 Share Posted April 18, 2011 Ok so when entering things into your lastupdated table i would do it like this: $date = time(); // returns somthing like 1303156571 then when you query in another file to see if anything has been "last updated" on the current day you would do; $current_date = time(); $sql = "SELECT * FROM top_5 WHERE lastupdated =".$current_date; Quote Link to comment https://forums.phpfreaks.com/topic/234092-difficult-where-clause/#findComment-1203204 Share on other sites More sharing options...
Xtremer360 Posted April 18, 2011 Author Share Posted April 18, 2011 Actually with the help of a good friend I was able to come up with what I needed and here it is hopefully for anyone can understand this and apply it if need be. WHERE year(`lastUpdated`) = year(now()) AND month(`lastUpdated`) = month(now()) Quote Link to comment https://forums.phpfreaks.com/topic/234092-difficult-where-clause/#findComment-1203207 Share on other sites More sharing options...
mikosiko Posted April 18, 2011 Share Posted April 18, 2011 easy way WHERE date_format(`lastUpdated`, '%Y%m') = date_format(now(), '%Y%m'); Quote Link to comment https://forums.phpfreaks.com/topic/234092-difficult-where-clause/#findComment-1203233 Share on other sites More sharing options...
Xtremer360 Posted April 18, 2011 Author Share Posted April 18, 2011 Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/234092-difficult-where-clause/#findComment-1203234 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.