MySQL Question

Transfer data from one table to another if data doesn't exist

I have 2 Tables in MySQL and they are:

enter image description here

As what you see on the Image above the The First 4 Rows of the Field

Item Code
of the Tables
General Inventory
and
Purchase Order
are the Same and the 5th row in the table
Purchase Order
are not in the table
General Inventory
. Now my Question is how can I achieve this? (Image Below)

enter image description here

as what you see on the Image above the Data from the field
Quantity
of Tables
General Inventory
and
Purchase Order
has been SUM because there preceding data under field
Item Code
is same and the Last one that has no equal value in the
General Inventory
table has been added.

Let me Shorten Up the Question.

How can I Sum Up the Data from the field
Quantity
of
Purchase Order
in the
General Quantity
if there Data in the
Item Code
field are the same else add the new data if the Data from
Purchase Order
doesn't exist in
General Inventory
.

I tried this code.

UPDATE GeneralInventory GI
INNER JOIN PurchaseOrder PO ON GI.ItemCode = PO.ItemCode AND GI.`Description` = PO.`Description` AND GI.Quantity = PO.Quantity
SET GI.Quantity = GI.Quantity + PO.Quantity


and the Output is this

enter image description here

Now I tried the Second Code

INSERT INTO GeneralInventory (ItemCode, `Description`, Quantity)
SELECT PO.ItemCode, PO.`Description`, PO.Quantity
FROM PurchaseOrder PO
LEFT JOIN GeneralInventory GI ON GI.ItemCode = PO.ItemCode AND GI.`Description` = PO.`Description` AND GI.Quantity = PO.Quantity
WHERE GI.ItemCode IS NULL


the output is this.

enter image description here

The data has been Repeated instead the the
Item 5
will be added.

Answer

First using LEFT JOIN you can get inserted the not matching rows into the GeneralInventory table

INSERT INTO GeneralInventory (ItemCode, `Description`, Quantity)
SELECT PO.ItemCode, PO.`Description`, PO.Quantity
FROM PurchaseOrder PO
LEFT JOIN GeneralInventory GI ON GI.ItemCode = PO.ItemCode AND GI.`Description` = PO.`Description` AND GI.Quantity = PO.Quantity
WHERE GI.ItemCode IS NULL

Then you can UPDATE the GeneralInventory's Quantity value with JOINing the tables

UPDATE GeneralInventory GI
INNER JOIN PurchaseOrder PO ON GI.ItemCode = PO.ItemCode AND GI.`Description` = PO.`Description` AND GI.Quantity = PO.Quantity  
SET GI.Quantity = GI.Quantity + PO.Quantity