1
I made this precedent to bring records from a table between dates, but I need to pass the date field of the table for the between command to work, 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 fix this?
Need to pass the DATE field of which Table ? I don’t understand.
– Diego Souza
All the tables I will use in this database have a date field, the name of the table to be consulted I passed by parameter, however, I need the date field of these tables to use in the "Where CAMPO_DATA between ..."
– rodrigom