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
sparun1607sparun1607 

How to do inner or sub-query for the same object in SOQL

Hi All,

 

Currently I'm facing an issue to select  the value from the same object. below here i provided the query. 

 

I'm migration java-j2ee application to a salesforce, thisbelow  query works in my sql. I'm trying to do the same here in SOQL.

But it doesn't works. Could somebody can help me.

 

SELECT DATA1__c, TEXT__c FROM PARAMETERS__c WHERE ( (TYPE__c = 'ADMINISTRATEUR') AND (KEY1__c LIKE 'MONTAGE%') (AND KEY2__c = '')) AND (DATA1__c IN (SELECT KEY1__c FROM Parameters__c WHERE TYPE__c = 'PERE_TECHNIQUE'))

 

Here in the above query i need to take the value where TYPE is based on 'TECHNIQUE' where KEY1__c should be matched to DATA1__c from the outer query.

 

Here query is very similar to below example

 

SELECT Id FROM Idea WHERE ((Idea.Title LIKE 'Vacation%') AND (CreatedDate > YESTERDAY)  AND (Id IN (SELECT ParentId FROM Vote WHERE CreatedById = '005x0000000sMgYAAU'))

The only difference is here they have used IN clause with different object, in my query i'm trying to use IN clause from the same object.

 

 

Kindly let me know in case of any further clarifications.