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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -