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
Gaurav-GuleriaGaurav-Guleria 

Not Exists query in Salesorce

Hi Guys,

 

Scenario:

1.Sites and Applications are parents of SiteApplications.

2.I want to fetch those Sites(Parent of SiteApplications) and Applications(Parent of SiteApplications) records which don't have SiteID(Lookup) and ApplicationID (Lookup) in SiteApplications(child).

 

Possible query in SQL:

Select ApplicationID, SiteID From Applications, Sites

 

Where ApplicationID, SiteID  NOT EXISTS

 

                                (Select ApplicationID, SiteID From SitesApplications)

 

How can I write this in SOQL.Please suggest.

PFA DB_SiteApp image for details.

 

Devender MDevender M
Hi


Select ApplicationID, SiteID From SitesApplications where ApplicationID = null or SiteID = null
Gaurav-GuleriaGaurav-Guleria

Hi Devender,

 

Thanks for your reply.

 

Sorry,There was typo error in the question.I have modified the text in Red.

 

Waiting for reply on this.

Devender MDevender M
Hi

You can use this query

Select ApplicationID, SiteID From SitesApplications where ApplicationID = null and SiteID = null
Gaurav-GuleriaGaurav-Guleria

Hi Devender,

 

I need to query Sites and Applications objects to fetch those Site and Application IDs which are not in Site applications table.

Devender MDevender M
There is no direct query for to get the records. need to think in other way. If we query like that it will fail when bulk records