Good Afternoon. I have two Tables and they are
WareHouseID | ItemCode | Qty Null Null Null
Note: as of now it is empty
and Table: Receiving
RINo | ItemCode | ReceivedQty RI805ZFJ FBMURG5WR 1.00 RI467RGR FBMURG5WR 1.00
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
I will click a button named
Postand the Program will do the Following
-Check if the
ItemCodeof the Selected
RINoalready Exist in the Table
GeneralInventoryand If the
ItemCodeis already in there then
GeneralInventorywill 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