Mysql queries 4 tables

0

Please help, -the products have material specified in the product detail table -the orders contain the products and their quantity ordered.

    
asked by davabun 18.07.2017 в 08:14
source

1 answer

1

Check that the names of tables and fields are the same, but it would be like this:

select materiales.id_material, nombre_material, CONCAT(sum(detalle_de_pedido.cantidad_p*detalle_de_producto.cantidad_m),' ',unidad_medida) as cantidad_total
from detalle_de_pedido inner join detalle_de_producto on detalle_de_pedido.id_producto=detalle_de_producto.id_producto inner join materiales on detalle_de_producto.id_material=materiales.id_material
group by materiales.id_material
    
answered by 18.07.2017 / 10:31
source