42

Can some one correct my soql? I need to export records in data loader like:

WHERE Id IN ('123123123','123123fsdf')

But this following query does not work for me:

SELECT Id, Syndication_Documents__c FROM ContentVersion 
WHERE Syndication_Documents__c in : 'a4fa0000000KzbV','a4fa0000000KzbW'

1 Answer 1

56

If it's not in Apex code you don't need the : and you need to add ( )

So your SOQL could be rewritten as:

SELECT Id, Syndication_Documents__c 
   FROM ContentVersion 
   WHERE Syndication_Documents__c IN ('a4fa0000000KzbV','a4fa0000000KzbW')

If you're doing it from Apex and have a Collection (Set, List, or Map) you can bind them to the query and avoid the string manipulation:

Set<Id> records = new Set<Id>{ 'a4fa0000000KzbV','a4fa0000000KzbW' }; //or an existing collection from elsewhere
List<ContentVersion> results = [SELECT Id, Syndication_Documents__c 
       FROM ContentVersion 
       WHERE Syndication_Documents__c IN :records];

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .