我有一个像这样的查询
select id, item, date producer from table
结果是这样的:
id item producer date
1 apple A 2013-10-26
2 pear A 2013-10-26
3 peach A 2013-10-26
4 orange B 2013-10-26
5 strawberry B 2013-10-27
6 melon B 2013-10-27
7 apple2 A 2013-10-27
8 orange3 A 2013-10-27
我需要将这些数据“按 DATE DESC 排序”打乱,并得到如下信息:
item producer
orange3 A
melon B
apple2 A
strawberry B
pear A
orange B
apple A
peach A
melon B
我不想这样显示:
ALL A ITEM ... ALL B ITEM ... 或者将今天添加的内容与昨天添加的内容混为一谈...在我的示例中,我不想在“orange3”之前显示“orange”
我的解决方案(但很慢)
Select * from table where date = $date order by rand;
Select * from table where date = $date -1 order by rand;
select * from table where date = $date -2 order by rand;
(这只是一个概念,$date不能用这个方法递减)