title: How to do inner or sub-query for the same object in SOQL
body: <p>I'm facing an issue to select the value from the same object. I provided the query below.</p>
  
  <p>I'm migrating a Java J2EE application to Salesforce, the below query works in my <code>SQL</code>.<br>
  I'm trying to do the same in <code>SOQL</code>, but it doesn't work.</p>
  
  
  
  <pre><code> 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'))
  </code></pre>
  
  <p>In the above query I need to take the value where <code>TYPE</code> is based on <code>'TECHNIQUE' where KEY1__c</code> should be matched to <code>DATA1__c</code> from the outer query.</p>
  
  <p>The query is very similar to this example</p>
  
  
  
  <pre><code> SELECT Id 
       FROM Idea 
       WHERE ((Idea.Title LIKE 'Vacation%') 
           AND (CreatedDate &gt; YESTERDAY)  
           AND (Id IN (SELECT ParentId 
                       FROM Vote 
                       WHERE CreatedById = '005x0000000sMgYAAU'))
  </code></pre>
  
  <p>The only difference is that <code>IN</code> clause is used with a different object.
  In my query I'm trying to use <code>IN</code> clause from the same object parameters.</p>
  
  <p>Kindly let me know in case of any further clarifications.</p>