1

I am trying to run a SOQL query in the dev console to get resultant records where a Contact's MailingStreet matches a particular LIKE query but can't seem to get any results even when I know it ought to.

Example: MailingStreet is 1234 Fancy Road

Query: SELECT MailingStreet FROM Contact WHERE MailingStreet LIKE '%Fancy%'

However this yields nothing. Is there something special about the built-in MailingAddress compound field or how you need to query it?

If this should be done via SOSL instead, could someone offer an example?

4
  • I just tried your query, it works fine for me. Just keep in mind that a leading wildcard results in a table scan, so if you have a lot of records, you might run in to selectivity problems. Have you tried SOSL?
    – sfdcfox
    Commented Jan 13, 2022 at 16:55
  • MailingAdddress isn't Shield Platform-encrypted by any chance? Normally you'd get an exception if you tried to do a LIKE query on an encrypted field)
    – cropredy
    Commented Jan 13, 2022 at 17:14
  • @cropredy I don't believe in my case that it is Shield encrypted since I get no exceptions but I'll have to check with an architect. I was just wondering if I was running the query wrong. Thank you though! sfdcfox I will have to try a SOSL approach or just use workbench to see if I get different results. Much appreciated for the quick feedback
    – trebleCode
    Commented Jan 13, 2022 at 17:17
  • Seems like it was a connection timeout issue. After awhile things started to return as expected. Thanks all
    – trebleCode
    Commented Jan 13, 2022 at 18:00

0

You must log in to answer this question.

Browse other questions tagged .