MySQL Forums
Forum List  »  Spanish

Calcular automaticamente el total
Posted by: Jose Andres Reyes Ortega
Date: November 13, 2022 05:06PM

SALUDOS!

He creado una tabla llamada ingresos en la que solo pondré los datos relevantes tal que así:

CREATE TABLE `INGRESOS` (
`ID_CONCEPTO` varchar(255) NOT NULL,
`DESCUENTO O AÑADIR` float NOT NULL,
`TOTAL` float NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


ALTER TABLE `INGRESOS`
ADD CONSTRAINT `INGRESOS_ibfk_3` FOREIGN KEY (`ID_CONCEPTO`) REFERENCES `CONCEPTO DE PAGO` (`CONCEPTO`) ON DELETE NO ACTION ON UPDATE NO ACTION;

Al añadir un nuevo registro a esta tabla se puede elegir el concepto de pago y poner una cantidad positiva o negativa en descuento o añadir.



A continuación añado la estructura de la tabla CONCEPTO DE PAGO:

CREATE TABLE `CONCEPTO DE PAGO` (
`NUMERACION` int(11) NOT NULL,
`CONCEPTO` varchar(255) NOT NULL,
`PRECIO` float NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;




lo que necesito es que `INGRESOS`.`TOTAL` sea igual a `CONCEPTO DE PAGO`.`PRECIO` más `INGRESOS`.`DESCUENTO O AÑADIR`.

Gracias.

Options: ReplyQuote


Subject
Views
Written By
Posted
Calcular automaticamente el total
965
November 13, 2022 05:06PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.