0
It has a table named Preco. Inside this table if you find the sale price and the cost of the product however, I cannot print in echo pq the name of the column is one and does not specify who is sale or cost.
EDIT Query to fetch product price:
SELECT Produto.Nome as Nome_do_Produto, Codigo_Fabricante1, Qtde, ProdutoPreco.Preco, TabelaPreco.Nome as Tabela, TabelaPreco__Ide
FROM TabelaPreco
INNER JOIN ProdutoPreco
ON ProdutoPreco.TabelaPreco__Ide = TabelaPreco.Ide
INNER JOIN Produto
ON ProdutoPreco.Produto__Codigo = Produto.Codigo
INNER JOIN Estoque_Atual
ON Produto.Codigo = Estoque_Atual.Produto
WHERE Filial = 1 AND (Produto.Nome like '%IMPERADOR%') AND Preco > 0 AND Qtde > 0
Result of the above consultation:
Nome_do_Produto Codigo_Fabricante1 Qtde Preco Tabela TabelaPreco__Ide
MAC ESPAG IMPERADOR FORTALEZA 500G 7891152234015 1.00000 2.2900000000 Preco 11627049-F321-42DE-A3ED-4101BADDBC32
MAC ESPAG IMPERADOR FORTALEZA 500G 7891152234015 1.00000 1.7000000000 Custo 1D05193A-5045-4592-AA17-E2C1EA4D9260
MAC PARAFUSO IMPERADOR 500G 7891152334142 41.00000 3.1900000000 Preco 11627049-F321-42DE-A3ED-4101BADDBC32
MAC PARAFUSO IMPERADOR 500G 7891152334142 41.00000 2.1800000000 Custo 1D05193A-5045-4592-AA17-E2C1EA4D9260
I need to print the two values separately in php but the values are in only one column (Price).
as I defined in php:
echo "EAN: " . $row_usuario['Codigo_Fabricante1'] . "<br>";
echo "Nome: " . $row_usuario['Name1'] . "<br>";
echo "Preco de Custo: R$"; echo number_format((float)$row_usuario['Preco'], 2, ',', '.'). "<br>";
echo "Preco de Venda: R$"; echo number_format((float)$row_usuario['Preco'], 2, ',', '.'). "<br>";
echo "Estoque: "; echo number_format((float)$row_usuario['Qtde'], 2, ',', '.'). "<br><br>";
Sorry but did not understand your description. You mean your product either has the cost price or the selling price, but not both, in the price field? It’s not a bit strange?
– anonimo
come on, the product has only one column for the cost and sale price, I can only separate them with Table.Name = 'Cost' in SQL query however, for echo I can only call the column price to print the cost or sale price
– Matheus Carvalho
only need to print cost and sale with the "echo"
– Matheus Carvalho
Maybe a self-assembly can be useful to recover the two prices.
– anonimo
Could you tell me how? There are two days I’m doing research to solve and I can’t at all
– Matheus Carvalho
by what I understand it will only join the information of the tables but my problem is that the information I need is in a single column
– Matheus Carvalho
When you have questions about queries it is important to leave in the question both the table template and information that is relevant so that other people can help you. It is also very useful if the code is simplified to focus on the question problem. In this case there is more data than necessary in the query, it is not possible to know to which Tablea the columns belong and it became very subtle the information that there are two "price" records that are in the same table, differing by the column
Nome
.– tvdias