Use stored procedures to make calculations between 2 tables.

0

I have these two mysql tables, one of routes.

Sales table:

What I'm looking for is to implement a stored procedure, so as not to burden the php application so much. Let the process take as inputs:

* tabla_rutas.num_corrida,

* table_sales.area_sales,

* table_sales.date-out

Based on these data, throw the following table, plotting the route of the run and in each row corresponding to a point of the route, count how many tickets (table_sales.num_boletos) were sold, with what origin and destination. And the total elimination (tabla_ventas.num_boletos).

Obtaining an output like the following, according to the data shown of the 2 previous images. I do not know if it's better to do that calculation with stored procedures, I think so.

The attention is greatly appreciated in advance.

    
asked by Armando Arellano 31.03.2018 в 04:28
source

0 answers