+ Start a Discussion
ArjunmcaArjunmca 

Lookup and Master-Detail Relationship

Hi,

 

I have to get data from three objects which have relationships. Objects, fields and their relationships are as follows.

 

1) Proudct ( standard Object)

     Field:  ProductCode,Offer_category__r

 

 

2) Product_Options__C ( Custom Object )

     Field: Name, Product_Option_code

     RelationShip: Lookup(Product)

 

3) RecurringPrice__C ( Custom Object )

     Field: Current_Price__c

     Relationship: Master-Detail ( Product_Options__c)

 

for better understanding i am writing the relationship

Product -->(LookUp) Product_Options__C -->(Master-Detail) RecurringPrice__c

 

I want to get the value of Current_Price__C.

 

 

 

//For understanding i am writing SQL  query

 

Select Current_Price__C where

   Product.productcode  = ProductOption__c.Product_Option_code and

   ProductOption__c.Product_Option_code = RecurringPrice__C.Product_Option_code

from RecurringPrice__C.

 

 

 

Can any one help me in writing the SOQL query to get the value of Current_Price__c.

 

Thanks.

 

 

 

 

 

 

 

 

 

 

AshlekhAshlekh

 

Hi ,

 

Try this 

 

Select Your fields form yourCustomObject where (Product_Options__C object relatation ship name + __r). (relation ship name of product on PO object).fieldname  =  (Product_Options__C object relatation ship name + __r).fieldname ;

 

This link can help you more

http://blog.jeffdouglas.com/2010/02/22/soql-how-i-query-with-thee-let-me-count-the-ways/

 

 

 

Thanks

Ashlekh

sandeep@Salesforcesandeep@Salesforce

If you have Product id then Please apply below : 

[Select Current_Price__C from RecurringPrice__C where Product_Options__r.ProductId = : PRODUCTID ]

 

Where PRODUCTID is id of Product for this you want to get current price.