You can create a PROCEDURE by creating a temporary table before running the query, for example:
DELIMITER //
CREATE PROCEDURE TempDateTable(data_ini DATE, data_fim DATE)
BEGIN
DECLARE v_curdate DATE;
SET @v_curdate = data_ini;
START TRANSACTION;
DROP TABLE IF EXISTS tempdatetable;
CREATE TEMPORARY TABLE tempdatetable (
data_tempo DATE NOT NULL PRIMARY KEY
);
WHILE @v_curdate <= data_fim DO
INSERT INTO 'TempDateTable'('data_tempo') VALUES (@v_curdate);
SET @v_curdate = ADDDATE(@v_curdate, INTERVAL 1 DAY);
END WHILE;
COMMIT;
END//
DELIMITER ;
Data
--------------------------------------
| data_tempo | contador | quantidade |
--------------------------------------
| 2014-09-01 | CDR_SUC | 256 |
| 2014-09-04 | CDR_SUC | 258 |
| 2014-09-05 | CDR_SUC | 195 |
| 2014-09-06 | CDR_SUC | 100 |
| 2014-09-10 | CDR_SUC | 317 |
--------------------------------------
Running Procedure
CALL 'databasetest'.'TempDateTable'('2014-09-01', '2014-09-10');
Conducting the query
SELECT tmp.data_tempo, test.contador, IFNULL(test.quantidade,0)
FROM tempdatetable as tmp
LEFT JOIN testedados as test ON DATE(test.data_tempo) = DATE(tmp.data_tempo);
Result:
--------------------------------------
| data_tempo | contador | quantidade |
--------------------------------------
| 2014-09-01 | CDR_SUC | 256 |
| 2014-09-02 | NULL | 0 |
| 2014-09-03 | NULL | 0 |
| 2014-09-04 | CDR_SUC | 258 |
| 2014-09-05 | CDR_SUC | 195 |
| 2014-09-06 | CDR_SUC | 100 |
| 2014-09-07 | NULL | 0 |
| 2014-09-08 | NULL | 0 |
| 2014-09-09 | NULL | 0 |
| 2014-09-10 | CDR_SUC | 317 |
--------------------------------------