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
SelvaSelva 

how to form the nested query in javascript?

Hi,
 
I am developing one S-control snippet (javascript) and using sforce.connect.query( )
am forming the nested query.
 
select t.tocOpportunityProductId__c from AgreementId__c
where t.tocOpportunityProductId__c in (select distinct tocOpportunityProductId__c from tfAgreementProduct__c)
 
the above query failed and saying error as the keyword "in" not found.
is there any other alternative method instead of "in" keyword"
 
Plz reply me
 
 
werewolfwerewolf
SOQL is not SQL.  There's no DISTINCT, and you can't do IN on a subquery.  IN only works when you give it an enumerated list of values, so you can make 2 queries, the first to do what your subquery would do, feed the results of that into a list, and then the second query with the IN on that list.

Or you can probably use a relationship query here if these objects are somehow linked to each other with lookup relationships.  Look up relationship queries in the API docs.