+ Start a Discussion
Dileep RatnayakeDileep Ratnayake 

SOQL returns null on LIKE query

Hi everyone,

I'm trying to run a query with LIKE condition but I get a null response when I add the LIKE condition.
 
SELECT Property__r.Geolocation__Latitude__s,Property__r.Geolocation__Longitude__s,Property__r.Name,Id,ListingHeadline__c,Name,PriceDisplayedWebsite__c,PropertySuburb__c,PropertyType__c,Property_Zone__c,Property__c,Reference__c,TotalFloorArea__c FROM Opportunity WHERE IsClosed=false AND PublishedToWebsite__c=true AND Reference__c LIKE '%JG%' AND Property__c IN (SELECT Id FROM Property__c WHERE PublishedToWebsite__c=true)

If I remove the 
Reference__c LIKE '%JG%'

part, it works fine I get the results.
And I can confirm it does have data that match the LIKE condition.

Any idea on what's wrong with the above query?
ANUTEJANUTEJ (Salesforce Developers) 
Hi Dileep,

Can you check once if you were able to get the records if only the like condition is applied and if you are getting any records if the like condition is changed to fit another set of records?

Looking forward to hearing back from you.

Regards,
Anutej
shaik murthujavalishaik murthujavali
Hi Dileep,
1). Firstly just make sure that both objects opportunity and property has the same field which is "PublishedToWebsite__c".
2). I think you need  to include "PublishedToWebsite__c" field in the query first since you can't use that field directly in where condition without querying that requested field.

If it works for you pls mark it as a best answer so that it helps others too.
Thanks.