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
magandrezmagandrez 

WHERE AccountNumber IN:= dataSet not working

Hi all,

 

I have a set of Customer IDs in dataSet variable, I want to build a SOQL with an 'IN' filter in the WHERE clause...but it's not compiling:

 

List<Account> AccIds = [SELECT Id FROM Account WHERE AccountNumber IN =: dataForUpdate];

 

Any idea of what is going on?

 

Greetings, 

 

MGA.

Best Answer chosen by Admin (Salesforce Developers) 
Devendra@SFDCDevendra@SFDC

 

Try this,

 

List<Account> AccIds = [SELECT Id FROM Account WHERE AccountNumber IN : dataForUpdate];

 

Thanks,

Devendra

All Answers

Devendra@SFDCDevendra@SFDC

 

Try this,

 

List<Account> AccIds = [SELECT Id FROM Account WHERE AccountNumber IN : dataForUpdate];

 

Thanks,

Devendra

This was selected as the best answer
magandrezmagandrez

Worked, thanks!

PanchoPancho

Hi,

I am having a similar problem.  I am moving this APEX code over to a JAVA app, and my query is not working.  

Any help is greatly appreciated.

Any ideas?

 

APEX Code:

List<String> zips = new List<String>();

//loaded up the list then I execute this query 

List<Zip_Code_Master__c> zipList= [select name, id, Related_Metro_Area__r.id from Zip_Code_Master__c where name =:zips];

 

 

JAVA Code:

String[] zips = new String[MaxRows];

//loaded up the list then I execute this query

QueryResult queryResults = connection.query("select name, id, Related_Metro_Area__r.id from Zip_Code_Master__c where name IN : zips");

 

JAVA Error:

[MalformedQueryFault [ApiQueryFault [ApiFault exceptionCode='MALFORMED_QUERY'
exceptionMessage='
Zip_Code_Master__c where name IN : zips
^
ERROR at Row:1:Column:80
unexpected token: ':' (Bind variables only allowed in Apex code)'
]
row='1'
column='80'
]