私は次のようなクエリを持っています
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 をデクリメントすることはできません)