as a side issue, since you happen to be online right now, maybe you can help with a query.
I need to query a products_pricing table (shown below) and and return ONLY one row per product, where that row is the lowest price for that product. Each product has several prices (rows) in this table.
So, of course, in my query i will ORDER BY price. But how do i only return the ONE, and ONLY, lowest price for each product?
Thanks.
Jonathan
Here's the table:
#Create products_pricing table. Pricing is a multi-valued attribute of
#the products table and thus has its own table shown below.
#item_num is a foreign key in this table and refers to the products table.
CREATE TABLE products_pricing (
item_num VARCHAR(20) NOT NULL,
quantity INT,
price DECIMAL(6,2),
code CHAR(1),
PRIMARY KEY (item_num, price, code, quantity),
INDEX (item_num),
FOREIGN KEY (item_num) REFERENCES products (item_num)
ON UPDATE CASCADE ON DELETE RESTRICT
) ENGINE=INNODB;