I have a product table that stores the "main" prices:
Products
===========.
identifier
partnum
description
price
installation time
Dealers can redefine the price of the list, set a different price, installation time, etc. I was thinking about storing the differences in the dealer settings in another table:
redefines
===========.
dealerID
partnum
price
installation time
When I request db for dealer prices, I need to join these tables. I need the values ββin the override table to override the values ββin the product table.
SELECT partnum, price, installtime FROM products JOIN overrides ON products.partnum = overrides.partnum WHERE dealerID = 123
As written, this, of course, will give an error. The fact is that I need a price from the redefinition table if it exists instead of the price in the product table (the same for instaltime). I could use different field names and move the logic to the PHP level. But SQL should be able to handle it, right?
join mysql
skypanther
source share