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
cad auscad aus 

SOQL - Unrelated Objects

Hi, 

Is it possible to join two unrelated objects (Account with Custom Object) using SOQL? 

Basically I need to update the Account object with a field from the unrelated custom object. Where Account.custom_field == Customobject.custom_Field.

The update can be done in bulk, hence governor limits (SOQL -100) should be respected.

Thanks!


 
ShirishaShirisha (Salesforce Developers) 
Hi cad,

Greetings!

I don't think this can be possible.If you would like to update the field on the Custom field with the value of Account field then it should have the relationship inbetween to query and fetch the value.

I would suggest you to create lookup relationship in between the Account and Custom Object to update the field on the Account or Custom Object viceversa.

Once,you have done the above part then create a batch class and update the records in bulk.

Kindly let me know if it helps you and close your query by marking it as best answer so that it can help others in the future.

Warm Regards,
Shirisha Pathuri
GauravGargGauravGarg
Hi Cad,

You can try using a nested query approach;
SELECT Id, Email
FROM Account
WHERE Email IN (SELECT Email FROM Contact)

Here object Contact is treated as Un-related object. 

Have a try and let me know if this works. 

Thanks,

Gaurav
Skype: gaurav62990