Jump to content

Order by record within month?


brmcdani

Recommended Posts

I am trying to create a mysql statment where the following records are pulled out based on which month it is.  The following statment I have will pull out the latest photos and order them by the date.  However I want it to pull out records only from the current month.

 

Any ideas will be appreciated.  Thanks

 

$sql="select * from members,photos where members.username=photos.username and approved='Y'  and active=1 order by photos.upldate";

Link to comment
https://forums.phpfreaks.com/topic/202187-order-by-record-within-month/
Share on other sites

Thanks I got figured it out as soon as you posted.  Here was my solution:

 

$sql="select * from members,photos WHERE members.username=photos.username and YEAR(upldate) = YEAR(CURDATE()) AND MONTH(upldate) = MONTH(CURDATE()) and approved='Y'  and active=1 order by photos.upldate";

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.