I have a table like this:
data |id
2017-02-01 00:00:00|1
2017-02-01 00:00:00|5
2017-04-01 00:00:00|2
2018-02-01 00:00:00|3
2018-04-01 00:00:00|4
Then I make a query with PHP in Mysql that brings me
SELECT id, data
FROM orders
GROUP BY data
and brings in php
foreach($results as $row){
echo date('m',$row->data).'<br/>';
}
The above result is:
02
04
02
04
But I wanted him to bring it together by year:
2017
02
04
2018
02
04