Quiero armar una base de datos que me guarde los producto que compro, lo que vendo de esos productos y una tabla que me diga el stock de esos productos...
la idea que se me ocurre es hacer un insert en la tabla compras con los datos del producto y en la tabla ventas otro insert con los productos. ahora en la tabla sotck como hago para que me aparezca la diferencia de las dos tablas anteriores (seria el stock de mis productos). les paso las dos tablas que tengo
Estare bien encaminado? que me recomiendan? Gracias espero me puedan ayudar
Código SQL:
Ver original
CREATE TABLE IF NOT EXISTS `t_salida` ( `id_salida` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `producto` text NOT NULL, `receptor` text NOT NULL, `ubicacion` text NOT NULL, `cantidad` INT(10) NOT NULL, `fecha` DATE NOT NULL, `remito_salida` text NOT NULL, `estado` text NOT NULL, `coment` text NOT NULL, `users` text NOT NULL, PRIMARY KEY (`id_salida`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;
Código SQL:
Ver original
CREATE TABLE IF NOT EXISTS `t_entrada` ( `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `producto` text NOT NULL, `proveedor` text NOT NULL, `ubicacion` text NOT NULL, `cantidad` INT(10) NOT NULL, `fecha` DATE NOT NULL, `remito` text NOT NULL, `estado` text NOT NULL, `coment` text NOT NULL, `users` text NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;