1

I'm trying to query for records that do not contain LTD or LLP in the name and are also not assigned to a certain record type. I have tried just about every variation with parenthesis and AND/OR conditions but jo joy. Can anyone help? Fields removed for simplicity.

SELECT Full_Name__c, Account.Name FROM CONTACT 

WHERE 

NOT(account.name LIKE '%LTD%' OR account.name LIKE '%LLP%') 

AND

(RecordType.Name != 'Broker' OR account.RecordType.Name != 'Broker')

ORDER BY account.name

Note that the below query does work:

SELECT Full_Name__c, Account.Name FROM CONTACT 

WHERE 

NOT(account.name LIKE '%LTD%' OR account.name LIKE '%LLP%') 

ORDER BY account.name
0

1 Answer 1

2

This is a bit of a guess but I think this is what you'd want. This would exclude the record if any of the listed conditions are true. I have changed your like query because I find it easier to read this way, but I believe yours should work too.

SELECT Full_Name__c, Account.Name
FROM Contact
WHERE (NOT Account.Name LIKE '%LTD%')
AND (NOT Account.Name LIKE '%LLP%') 
AND RecordType.Name != 'Broker'
AND Account.RecordType.Name != 'Broker'
ORDER BY Account.Name
1

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