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
guest1231231guest1231231 

Union Query in SOQL?

Is it possible to do a union query within SOQL?

 

Thanks

SuperfellSuperfell

No, can you give an example of how this would be useful ?

KaukasKaukas

Hello.

 

Here is one example. We have a custom external id on both Leads and Accounts which identifies a company. We want to find out which companies are on SalesForce - Accounts + Leads. Here's the query which naturally comes to my mind:

 

 

Select company_id__c From Account
Union
Select company_id__c From Lead;

 

 

I have to issue two separate queries instead.

 

Cheers!

Linas