1
I have this SELECT
in my BD however I need one of the columns to store the value generated by lucro
, I already have a profit column created as DOUBLE
but it does not store that information
SELECT
that I’m wearing:
SELECT pac.ID_Pacote, pro.Nome, pac.peca, pac.FK_ID_Produto,
pac.Quantidade, pac.Data_entrada, pac.Data_saida,
CONCAT('R$ ', ROUND(pac.Quantidade * pro.Preco, 2)) AS Lucro
FROM pacote pac
INNER
JOIN produto pro
ON pac.FK_ID_Produto = pro.ID_Produto
Bank code
CREATE DATABASE ProdPacote;
USE ProdPacote;
CREATE TABLE Produto(
ID_Produto INT PRIMARY KEY AUTO_INCREMENT,
Nome VARCHAR (200) NOT NULL,
Descricao VARCHAR (200) NOT NULL,
Preco DOUBLE NOT NULL,
`status` CHAR (10) NOT NULL);
CREATE TABLE Pacote(
ID_Pacote INT PRIMARY KEY AUTO_INCREMENT,
Nome VARCHAR (200) NOT NULL,
peca VARCHAR (200) NOT NULL,
FK_ID_Produto int NOT NULL,
Quantidade INT NOT NULL,
Data_entrada DATE NOT NULL,
Data_saida DATE,
Lucro DOUBLE,
CONSTRAINT fk1
FOREIGN KEY (FK_ID_Produto)
REFERENCES Produto(ID_Produto));
so calm down, I would have to do this insert into the Quary of my correct project ?
– Pietro Nunciaroni
I also put the code of the bank because it is generating some errors of a table Profit.Prodpackage does not exist (what in BD is not to have)
– Pietro Nunciaroni