I have a query that show results of projects being worked between 2 dates. I would like the results to show me something like this
For: 2011-07-11
- Result 1
- Result 2
- Result 3
For: 2011-07-12
- Result 4
- Result 5
etc…
So it’s showing me the results split by date. Is that possible with a MySQL query ? Or I will need to make a query for each date ?
Thanks
So there really isn’t a way to make this sort of query ‘classy’ if you’re going to be pulling all of the information from a single query. You can’t make anything other than a rectangular table and therefore can’t represent many-to-one, one-to-many, or many-to-many relationships in a classier way. If you want to do something like this I would recommend using a server-side scripting language to take care of it for you and display it however you want (that is unless this isn’t a web-based application, then just use a non-web language).
In order to pull all the data and group/sort by the date, you would do the following:
This will pull all records from the table, group them by their relevant dates, and then sort them in ascending order by the date value(s).