i have 2 mysql tables:
- tbl_product: product_id, product_name, update_time, sale
- tbl_child_product: child_id, child_name, child_price, product_id
how select product sale='1', order update_time, lowest price per product (store in child_price in tbl_child_product table) 1 query?
thank you!
you join between tbl_product , aggregate query on tbl_child_product:
select p.product_id, p.product_name, c.lowest_price tbl_product p join (select product_id, min(child_price) lowest_price tbl_child_product group product_id) c on p.product_id = c.product_id order p.update_time
Comments
Post a Comment