All pastes #44542 Raw Edit

Stuff

public text v1 · immutable
#44542 ·published 2006-03-05 11:38 UTC
rendered paste body
select date_sub(current_date, interval tens.i*10 + units.i day) as ddate from integers as units cross join integers as tens where tens.i*10 + units.i between 0 and 30 order by ddate desc

this gives results like:

+------------+
| ddate      |
+------------+
| 2006-03-05 |
| 2006-03-04 |
| 2006-03-03 |
| 2006-03-02 |
| 2006-03-01 |
| 2006-02-28 |
| 2006-02-27 |
| 2006-02-26 |
... etc

I then want to left join this against a table of messages on ddate=me_date with a count on me_id to get totals for every day. How do I join this date list above with the subsequent table?