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
Jeanette Albert 15Jeanette Albert 15 

Error on SOQL query

I get an error before the AND is the last statement. (Description LIKE '%POI Document%') AND LastModifiedDate"

I changed it to WHERE and nada. It verified at OR but that pulled too many records.


SELECT Id, Name, Body, Description, ContentType FROM Attachment WHERE (Description LIKE '%Envelope%') OR (Description LIKE '%PNL Document%') OR (Description LIKE '%OOS Document%') OR (Description LIKE '%POI Document%') AND LastModifiedDate >= YESTERDAY AND LastModifiedDate < TODAY
 
There has been an error in the SOQL query: MALFORMED_QUERY: (Description LIKE '%POI Document%') AND LastModifiedDate >= YESTERDAY ^ ERROR at Row:1:Column:219 unexpected token: AND
@Karanraj@Karanraj
Use all your OR statement in a single bracket.
Try the below query
SELECT Id, Name, Body, Description, ContentType FROM Attachment WHERE (Description LIKE '%Envelope%' OR Description LIKE '%PNL Document%' OR Description LIKE '%OOS Document%' OR Description LIKE '%POI Document%') AND LastModifiedDate >= YESTERDAY AND LastModifiedDate < TODAY

 
Rohit K SethiRohit K Sethi
Hi Jeanette Albert,

We have a limitation that we cannot  include text area field in where condition of soql query.
And you are using the Description field that is why it raise an error.

 Thanks.