SELECT CONCAT(`date`,',',`viewcount`)
FROM `stat`
WHERE `stat`.`id` = 1
AND `channelstat`.`date` BETWEEN (SELECT DATE_SUB(NOW(), INTERVAL 90 DAY)) AND NOW()
This query work well and gave me result of last 2 days in CSV kind of format.
I think to generate whole csv file in MySQL. I tried to write my command to do it. When I tried GROUP_CONCAT it's not work well. Now I got rows from date less then 4 August. I am amazed because first queries make it from less then today.
SELECT GROUP_CONCAT(CONCAT(`date`,',',`viewcount`) SEPARATOR '\r\n')
FROM `stat`
WHERE `stat`.`id` = 1
AND `stat`.`date` BETWEEN (SELECT DATE_SUB(NOW(), INTERVAL 90 DAY)) AND NOW()
in second queries the last 2 line are which is totally invalid
2013-08-04,798
2013-08-
Somebody please tell me why it's not work. Why last line is different when rows are available from today to last 4 months.
The second queries have bugs like
invalid group concat or I am missing something.