I am making a project on the online shopping site. there i am having on table for product details and other for stock details
the two tables are like this
ProductInfo
Column Name Data Type Constraint
ProductID Int Primary key , auto increment
ProductName Varchar(100)
SubCategoryID Int Foreign key with ProductSubCategory
CompanyID Varchar(20) Foreign key with CompanyInfo
Price Float
Quantity Int
Description Varchar(1000)
ProductStock
Column Name Data Type Constraint
StockID Int Primary key,auto increment
ProductID Int Foreign key with ProductInfo
Quantity Int
StockType Varchar Check(‘IN’,’OUT’)
StockDate Datetime
now initially i have kept the value of quantity of productinfo = 0 and want increment or decreement it on the basis of value of quantity of ProductStock depending upon StockType
If stock is 'In' then increment the quantity of productinfo by the number=value of quantity of ProductStock
If stock is 'Out' then decrement the quantity of productinfo by the number=value of quantity of ProductStock
What query should i made to made this operation?