WHERE clause in SOQL query to history object (to custom field)

I am querying in the Workbench with SOQL.
I need to query a history object to a custom field, but I want to see changes only to a certain field. What is the syntax to say WHERE Field = MyTargetField ?

I tried this:

SELECT Field, NewValue, OldValue 
FROM MyCustomObject__History
WHERE Field = myTargetField__c

but this generates an error:

MALFORMED_QUERY:
WHERE Field = myTargetField__c

ERROR at Row:3:Column:14
Bind variables only allowed in Apex code

Answer

You need to wrap the value in single quotes ('...'):

SELECT Field, OldValue, NewValue
FROM MyObject__History
WHERE Field = 'Custom_Field__c'

Attribution
Source : Link , Question Author : ALisboa , Answer Author : Adrian Larson

Leave a Comment