12.08.2017, 18:30
Hi, I've decided to get rid of these "ItemPriceX" columns from my businesses table and create a separate table called "businessprices" that stores every business' item prices. There are 3 columns - "ID", "Item", "Price". When a business is created all the prices are 0 so there's no need of inserting the item price rows. However when you set the item's price I want it to insert a row into "businessprices" if one doesn't exist or update an existing row with the new price. I know there's "INSERT INTO ... ON DUPLICATE KEY UPDATE" for that, but I'm not sure how to use it. I've been googling quite a lot and trying, but I don't know how to get it working. I'd really appreciate that if someone explained me how this works and how to get it working.