 # Creating a Procedure for Comparing Two Tables

Hello I have four tables with the same fields;
Table 1: Table "New stock"
Table 2: "Stock" table
Table 3: Table of the new article for the update
Table 4: Table for items that come out of stock.

I want to compare Table1 with table 2 and I infect the result with table 3 or table 4 according to these conditions:
• If the quantity of the item from table1 <to the quantity of the item in table 2
 Then insert the row of the item from table 1 to table 3 with a quantity T2.quantity-T1.quantity and if the item exists in table 3 sum the quantities (T2.quantity-T1. Quantity) + T3.quantity).
• If the quantity of the item from table1> to the quantity of the item in table2
 Then insert the row of the item from table 1 to table 4 with a quantity T1.quantity-T2.quantity and if the item existed in table 4 sum the quantities (T1.quantity-T2. Quantity) + T4.quantity).
• If the quantity of the item in table 1 and table 2 is equal then nothing is done
• If the item does not exist in table 1
 Add to table 3 and sum the item also exists
• If the item does not exist in table 2
 Add to table 4 and sum the item also exists