I made this procedure to bring records of a table between dates, but I need to pass the date field of the table to the command between function, follow the code:
DELIMITER //
CREATE PROCEDURE pro_get_gastos(nome_tabela VARCHAR(20), data_ini DATETIME, data_fin DATETIME)
BEGIN
SET @tabela = CONCAT('SELECT * FROM ',nome_tabela,' WHERE ', AQUI TERIA QUE PASSAR O CAMPO DATA, 'BETWEEN', data_ini, ' AND ', data_fin,'''')
PREPARE consulta_gastos FROM @tabela;
EXECUTE consulta_gastos;
END //
How can I resolve this?