title: My mySQL stored add update delete procedure replaces the last entry in the table whenever I add a new entry
body: <p>Experienced with Oracle and Microsoft SQL, but super new to mySQL and have never encountered this problem before. Any thoughts? Code below</p>
  
  <pre><code>CREATE PROCEDURE spAddUpdateDelete_Product (IN productId INT, IN title VARCHAR(200), IN description VARCHAR(200), IN price FLOAT, IN categoryId INT, IN toDelete BIT)
  BEGIN 
      IF productId = 0 THEN                                                           -- Add
          IF EXISTS(SELECT productId FROM Product WHERE title = title AND description = description AND price=price and categoryId = categoryId) OR NOT EXISTS(SELECT categoryId FROM Category WHERE categoryid=categoryid) THEN
              SELECT -1;
          ELSE 
              INSERT INTO Product (productTitle, description, price, categoryId) VALUES (title, description, price, categoryId);
              SELECT LAST_INSERT_ID();
          END IF;
      END IF;
      IF toDelete = 1 THEN                                                            -- Delete
          IF EXISTS(SELECT reviewId FROM Review WHERE productId=productId) THEN
              UPDATE Product SET toDelete = 1 WHERE productId = productId;
              SELECT 0;
          ELSE 
              DELETE FROM Product WHERE productId = productId;
              SELECT 0; 
          END IF;
      END IF; 
  
      IF EXISTS(SELECT productId FROM Product WHERE productId=productId) THEN         -- Update
          UPDATE Product SET productTitle=title, description=description, price=price, categoryId=categoryId;
          SELECT productId;
      ELSE
          SELECT -1;
      END IF;
  END $$
  </code></pre>