Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return results for all days in range 1

Status
Not open for further replies.

Horrid

Programmer
May 20, 1999
373
I am trying to get the count of all entries per day for 14 days. Days where there are 0 results I want to return as 0. My current SQL that gets the data I need but only for the days with data:

select COUNT(ID), DATE_FORMAT( madeTime, '%Y%m%d') from test where topicID=X group by DATE_FORMAT( madeTime,'%Y%m%d') LIMIT 14;

I want to avoid a combined php/mysql solution and just have mysql give me all days. Any hints?

Thanks

 
Since your table test does not have data for the days with no activity you can not report on them.

YOu will need to create another table with all possible dates and the join this new table with your test table with a left outer.

Ian
 
Thanks. I thought as much. I just used php to pad the missing days.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top