Answer the question
In order to leave comments, you need to log in
How to display data from mysql grouped by month?
Hello, I have a table with the following structure
CREATE TABLE IF NOT EXISTS `data` (
`id` int(8) NOT NULL AUTO_INCREMENT,
`price` varchar(10) DEFAULT NULL,
`date` int(8) DEFAULT NULL,
`comment` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2013
Январь
-запись
-запись
-запись
Февраль
-запись
-запись
-запись
......
2014
Январь
-запись
-запись
-запись
Февраль
-запись
-запись
-запись
Answer the question
In order to leave comments, you need to log in
In general, the grouping problem was in the timestamp date, there are two options either to make the field in the database not int, but date or leave int and use FROM_UNIXTIME (unix_timestamp) in the request. The
request, approximately, in my case, looks like this
Here there is a selection by years, then in a loop in a similar query we display months and records for them
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question