Good Afternoon. I have two Tables and they are
Table: GeneralInventory
and Table: Receiving
As you can see this formats on Table are most likely you will see in Inventory System, My Table GeneralInventory
is the Main Inventory where all Items that you will received will transfer here and that Table is Receiving
as what you see in the table Receiving
there 2 Data and they are.
Please be focused on the RINo field they are Different right? now here is what I will do and also my Question (I will convert my Question in Step by Step procedure of the Program)
The Program will Select 1(One) Data from Table
Receiving
I will click a button named
Post
and the Program will do the Following-Check if the
ItemCode
of the SelectedRINo
already Exist in the TableGeneralInventory
and If theItemCode
is already in there thenReceivedQty
of tableReceiving
andQty
of TableGeneralInventory
will sum up or else add the Data.
I hope you get my point but if not I will show you further Example.
In General: If the Data Exist then Sum it Up or Else add the New Data.
I am using this Code.
INSERT INTO GeneralInventory (ItemCode, Qty)
SELECT RE.ItemCode, RE.ReceivedQty
FROM Receiving RE LEFT JOIN
GeneralInventory GI
ON GI.ItemCode = RE.ItemCode AND GI.Qty = RE.ReceivedQty
WHERE RE.RINo = 'Data of RINo'
UPDATE GeneralInventory GI
INNER JOIN receiving RE
ON GI.ItemCode = RE.ItemCode AND GI.Qty = RE.ReceivedQty
SET GI.Qty = GI.Qty + RE.ReceivedQty RE.RINo = 'Data of RINo'
TY for future Help