1
Note that if I perform an INNER JOIN in the three tables, I would return only product 1 (Router), which is present in the three tables. However, I would need him to return all results to me, but without repeating information. Ex.:
If I have 7 Routers in the table estoque1
and 9 routers in the table estoque2
, I would need the final result to be 16 routers.
And would also need you to return all results that were related to the table cadastro_produtos
.
The expected result would be:
How can I proceed in this case?
Neto, which SQL do you use? SQL-server, Mysql or other.
– Leonardo Bonetti
Using Mysql. Web application
– WebCraft
I no longer think this solves: SELECT product.id,product.name,sum(general stock.quantity) quantity From cadas_product the products LEFT JOIN ( (SELECT c_prod,quantity FROM stock1) UNION (SELECT c_prod, quantity FROM stock2) ) general stocking ON stock.c_prod = product.id GROUP BY product.id,product.name ORDER BY product.id
– Marcus Italo