sql - Query multiple tables -
i have following tables
customers (id, name) customerpricerelations (customer_id, sales_price_id) # jointable salesprices (id, margin) productsalesprices (product_id, sales_price_id) # jointable
given customer , product, want fetch matching salesprice. i'm kind of stuck , appreciate help
this mssql aren't using, should help. walk relations know until don't know.
select sp.id, sp.margin salesprices sp left outer join productsalesprices ps on sp.id = ps.sales_price_id left outer join customerpricerelations cr on ps.sales_price_id = cr.sales_price_id left outer join customers c on cr.customer_id = c.id c.id = <your customer id> , ps.product_id = <your product id>
Comments
Post a Comment