+ Start a Discussion
clouddev@surashriclouddev@surashri 

Using multiple LIKE in single SOQL

Hi,

 

I have a query where its checking multiple email domain like @gmail.com , @hotmail.com etc.

 

The query is like

 

SELECT company FROM lead WHERE email LIKE '%@gmail.com' OR email LIKE '%@hotmail.com'.

 

If I have to check more that 100 email domains in one go then it is exceeding 100 SOQL limit and giving "Too many SOQL queries: 101".

 

Is there any alternative syntax to achieve this task ?

 

Please reply,

 

Thanks,

 

clouddev@surashri

Anoop yadavAnoop yadav
Hi,
Try Like This:

String[] filters = new String[]{'%@gmail.com','%@hotmail.com'};
List<Lead> leads = [select id, name from Lead where Email like :filters];
clouddev@surashriclouddev@surashri

Hi,

 

Will that get over Too many SOQL queries: 101 error. That is my concern.

 

Thanks,