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
kk909kk909 

SOQL: To Retrieve Data from two Unrelated Sobjects

Hi ! I have to get data from 2 SObjects which have no relationship.

 

SObject 1:

 

SUPPLIERS      

 

SUPPLIER_NUMBER    SUPPLIER_NAME           STATUS                      CITY

------------------------------------------------------------------------------------------------------------------

S1                                           abc                                      20                          MUMBAI        

 

 

Sobject 2:

 

Project

 

Project_Number    Project_Name     City     

______________________________________

          J1                       SORTER           Chennai

          J2                       Display              Nellai

     

 

The Query Is : "Get supplier number for suppliers who supply Project J1".

 

Please give your suggestions.

 

Thanks..

 

AshishyadavAshishyadav

pretty odd question ... then how you are maintaining  that for J1 project who are the suppliers

kk909kk909
This is a part of Query practice questions. I do not have an idea, how to solve such queries.
admintrmpadmintrmp
If you have multiple suppliers for a project, you will need to have a third object to link the two together.

So you would have in layer order:

1. Project
2. Project Supplier
3. Supplier

The project supplier is simply a link between the project and supplier.

You can then run a query on the project supplier object to bring together the two objects:

SELECT Id, Project__r.Name, Supplier__r.Name FROM ProjectSupplier__c WHERE Project__c=:PROJECT_ID
kk909kk909
I will check the schema one more time.