0

I am facing a problem when trying to filter the leads and contacts that come from CRM to be used in email marketing.

The idea is that the filter does not add people who have the field conta.Name equal to Company in the last line..

For this I tried to use the not equal operator, but it still doesn't work, even putting it like this <>.

Would anyone know how to help me in this matter?

enter image description here

1

The <> operator is the correct one, but I believe there's something else that's making the query give you incorrect results.

Try grouping your conditions in the WHERE sections with parentheses. Your code looks pretty much like this:

WHERE
    Condition-1 OR Condition-2
    AND
    Condition-3 OR Condition-4 AND Condition-5
    AND
    Condition-5
    AND
    Condition-6

This is readable since you have line breaks, but you need to group logical conditions like this:

WHERE
    (Condition-1 OR Condition-2)
    AND
    (Condition-3 OR Condition-4) AND Condition-5
    AND
    Condition-5

Basically never mix AND with OR operators on the same logical level.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.