I have a scenario where I need to query all the records which do not have field value contains Customer , but need to include Customer System and other records.
Name | API Source| Email
Record 1 | Customer System|[email protected]
Record 2 | Customer|[email protected]
Record 3 | From Web|[email protected]
Record 4 | System A|[email protected]
In the above example I need to exclude the record 2 and 4 as they do not match my criteria, but need to query all other records. I have tried something like this:
Set<String> excludeSource = new Set<String>{'%Customer%'};
Set<String> inlcudeSource = new Set<String>{'Customer System'};
List<lead> lst Leads = [
SELECT Id, Name, Status
FROM lead
WHERE email = '[email protected]' AND (
(NOT APISource__c LIKE : excludeAPISource)
OR APISource__c IN :includeAPISource
)
]
but it does not work as exclude condition excludes all the records.is the a way to handle this scenario in single SOQL query?