Is it possible to get random items inside the same day?
For example:
+----+---------------------+ | id | md | +----+---------------------+ | 1 | 2010-06-27 11:26:01 | | 2 | 2010-06-27 11:28:20 | | 3 | 2010-06-27 11:29:46 | | 4 | 2010-06-27 11:30:50 | | 5 | 2010-06-27 12:20:56 | | 6 | 2010-06-27 12:27:42 | | 7 | 2010-06-27 15:14:05 | | 8 | 2010-07-06 01:53:33 | | 9 | 2010-07-06 01:52:52 | +----+---------------------+
I want to pick random items inside the same day, but at same time i want it ordered by date desc. Something like this:
+----+---------------------+ | id | md | +----+---------------------+ | 8 | 2010-07-06 01:53:33 | random block | 9 | 2010-07-06 01:52:52 | | 2 | 2010-06-27 11:28:20 | random block | 4 | 2010-06-27 11:30:50 | | 1 | 2010-06-27 11:26:01 | | 6 | 2010-06-27 12:27:42 | | 3 | 2010-06-27 11:29:46 | | 5 | 2010-06-27 12:20:56 | | 7 | 2010-06-27 15:14:05 | +----+---------------------+
No idea how to start or if this is even possible since order by rand() won't accept grouping.
You can use a WHERE clause...
Then just use PHP to insert whatever the date is into the string there for each date.
Or to use only one MySQL query, simply order them by date descending and pull them all out using PHP...
really simple:
If I have understood your question correctly, this should do the trick:
Example:
Probably not very efficient, but try