如何使用 foreach 循环 MYSQL month at 将 month 添加到 PHP 中的 +1 month?

How to use foreach loop MYSQL month at to add month to +1 month in PHP?

我将 MYSQL(参考代码 https://www.w3schools.com/sql/trysql.asp?filename=trysql_select_all)编码为:

SELECT * FROM [Orders]
WHERE OrderDate LIKE '1996-01-%'

当前结果仅显示订单日期为 1996-01-01 至 1996-01-31。

我希望结果在 PHP 中循环 MYSQL 个月到 +1 个月。

Example to real result :

show OrderDate of 1996-02-01 to 1996-02-28
show OrderDate of 1996-03-01 to 1996-03-31
...
show OrderDate of yyyy-mm-dd to yyyy-mm-dd

以后可以这样使用,编程结束就可以合并数据了

select *,max(case when month(OrderDate)=1 then OrderDate end) Jan,
max(case when month(OrderDate)=2 then OrderDate end) Feb,
max(case when month(OrderDate)=3 then OrderDate end) Mar,
max(case when month(OrderDate)=4 then OrderDate end) Apr
from Orders
group by month(Orders.OrderDate)`