我有一个广义搜索,我正在查找一周中不同日子的平均价格。问题是我不确定如何要求奇数范围。1-7 工作正常,(周一至周日),但如果用户从周日到周二... 即 7-2 它不起作用。
1-7 (1,2,3,4,5,6,7) 7-2 (7,1,2)
等等
除了 BETWEEN 之外,我还能如何通过更智能的范围或其他东西?
SELECT item_id, DAYOFWEEK(bookdate) as date, bookdate, AVG(price) AS price
FROM `availables` WHERE (item_id = 16 and DAYOFWEEK(bookdate) BETWEEN 2 AND 7)
GROUP BY DAYOFWEEK(bookdate)