I am having trouble figuring out the best way to approach this problem,
I have two different list of items, one in the DB, one not. Both list have item ids and quantity, I need to merge the two list into the DB.
My first inclination is to just pull all of the items out of the DB then merge the two list in the application logic. I would then delete the old list from the DB and insert the new merged list.
I figure I could also update/inserts for each of the items I want to merge into the DB, however this would mean many queries (maybe there is a stored procedure I could write, but i am not that hot with stored procedures).
I would like to know if SQL or application logic will perform better in this situation?
I would also like to hear how others would tackle this problem.
thanks.
UPDATE:
Here are some more details,
This is not a one time merge, it will happen several times. Basically I have an object in my application that holds a list of items, eventually these items need to be put into the DB. There is already items in the DB, so I can not just insert the items, I must increase the quantity of an item in the DB if two items have the same id and insert items with unique ids.
ONE MORE UPDATE:
using MySQL and PHP