function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Josh GitogoJosh Gitogo 

Can I pull up records from a 2 objects that have a look-up relationship?

I have custom object A that had a lookup relationship with custom object B. on a Visualforce page I want to pull up records from custom object B. I would make a master detail realtionship but custom object B already has one. Any thoughs on if this is possible?
 
Rahul KumarRahul Kumar (Salesforce Developers) 
Hi Josh Gitogo,

 Retrieve data from Lookup Relationship object We Can Query based on
 SOQL Relationship.

Basic Examples of SOQL RELATIONSHIPS:

Child > Parent (Standard Object)

 
Selectid,Account.Name,Account.Phone,Account.industry,Account.Type,Account.Rating,Account.website,Account.Ownership,Account.AnnualRevenue,Account.NumberOfEmployees,Account.CleanStatus from Contact


Child >Parent(Custom Object)
 
Selectid,COLLEGE__r.Name,COLLEGE__r.Contact__c,COLLEGE__r.Count__c,COLLEGE__r.Highest_Marks__c,COLLEGE__r.Address__cfrom Studnt__c

Parent >Child(Standard object)
select Name, Industry, (select AssistantName, Email from contacts)from ACCOUNT


Parent >Child (Custom Object)
select id,Name,(select Studnt__c.name__c from Studnts__r) from College__C
I hope it will be helpful.

Please mark it as best answer if the information is informative.

Thanks
Rahul Kumar