I have this database structure
username logged_in logged_out
------------------------------------------
user1 2011-04-03 19:32:01 2011-04-05 03:41:34
user2 2011-04-01 10:33:42 2011-05-01 23:15:23
What I need is a list of all users that were logged in on a specific day, so e.g.
day logged users
2011-04-01 user2
2011-04-02 user2
2011-04-03 user2
2011-04-03 user1
2011-04-04 user2
2011-04-04 user1
2011-04-05 user2
2011-04-05 user1
...
2011-05-01 user2
I'm currently trying to get this done with a single SQL query, but I don't really have a clue how to get the timespan of all days that are logged in the table and how to connect them to the users logged in.
My biggest problem is how to create the "virtual" table of all days spanned in the database...