mysql - Complicated condition in JOIN -
i have 1 table products, , second prices. 1 product can have mupltiple prices.
important columns of table products
id, name
important columns of table price
availability, price, supplierid
i need join price has availability > 0 , has lowest price.
more details performance:
- more million products means more prices
- index on pri.productid can added more
also need able order these results name of product or price
something like:
select * products pro join prices pri on pri.productid = pro.id , min(pri.price) , pri.availability > 0
select * products pro join ( select productid, min(price) mprice, availability prices availability > 0 group productid ) pri on pri.productid = pro.id
Comments
Post a Comment