1

I want to get all email addresses which contain @gnail.com, @gmeil.com or @gmai.com from DB. I have access only to Workbench and Salesforce Inspector and will need to execute the query periodically.

I tried code as in Multiple LIKE in SOQL

 SELECT CreatedDate,PersonEmail FROM Account WHERE Country__c = 'UA' AND Account.PersonEmail LIKE '%@gnail.com%' OR Account.PersonEmail LIKE '%@gmeil.com%' OR Account.PersonEmail LIKE '%@gmai.com%'

Error: unexpected token: OR

Also I tried a variant:

SELECT CreatedDate,PersonEmail FROM Account WHERE Country__c = 'UA' AND PersonEmail LIKE ('%@gnail.com%', '%@gmeil.com%', '%@gmai.com%')

gives an error: Bind variables only allowed in Apex code

1 Answer 1

1

welcome to the community.

You need to put brackets around your Likes, because I assume you want a AND (b OR c OR d).

SELECT CreatedDate,PersonEmail FROM Account WHERE Country__c = 'UA' AND (Account.PersonEmail LIKE '%@gnail.com%' OR Account.PersonEmail LIKE '%@gmeil.com%' OR Account.PersonEmail LIKE '%@gmai.com%'). Try this, should produce correct result.

P.S. do you really need @gmeil.com?

1
  • You're awesome. Yes, gmeil and other are typos of gmail. I extract and replace them
    – Guest
    May 17, 2021 at 6:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .