+ Start a Discussion
JoyJobingJoyJobing 

using AND in WHERE clause? getting error - it must be easy...

 I'm getting the following error on this line of code:  

Save error: Unexpected token: 'AND'

 

List<Task> newestTask = new List<Task> ([SELECT id, ActivityDate, AccountId FROM Task 													WHERE Owner_Matches_Account_Owner__c AND IsClosed AND ID in :ids									ORDER BY ActivityDate DESC LIMIT 1]);

 I know it must be obvious, but I can't figure out what's wrong with the multiple clauses in the WHERE section?  Any ideas?

Best Answer chosen by Admin (Salesforce Developers) 
Kiran  KurellaKiran Kurella

You need to check the boolean value with true or false like this:

 

List<Task> newestTask = new List<Task> ([SELECT id, ActivityDate, AccountId FROM Task WHERE Owner_Matches_Account_Owner__c = true AND IsClosed  = true AND ID in :ids ORDER BY ActivityDate DESC LIMIT 1]);

All Answers

Kiran  KurellaKiran Kurella

You need to check the boolean value with true or false like this:

 

List<Task> newestTask = new List<Task> ([SELECT id, ActivityDate, AccountId FROM Task WHERE Owner_Matches_Account_Owner__c = true AND IsClosed  = true AND ID in :ids ORDER BY ActivityDate DESC LIMIT 1]);

This was selected as the best answer
JoyJobingJoyJobing
yup...i knew it was easy... <facepalm>