Héléna Héléna - 29 days ago 5
SQL Question

SQL SERVER: where clause doesn't work in some way

Hi I have a question regarding

SQL SERVER
where
filter clause.

enter image description here

SELECT
Person

WHERE
region NOT LIKE '%France%'
AND region NOT LIKE '%America%'
AND Country NOT LIKE '%France%'
AND COUNTRY NOT LIKE '%America%'

OR Region IS NULL
OR Country IS NULL


By using this code, it displays Joh/Lily/HU.

How can the result only appears results that not contain words 'France' and 'America'? The the result should be Lily/HU.

Many thanks in advance.

Answer

From one of your comments:

I don't want to display anything containing "France" in either Region or Country column, but also displays those with NULL rows.

SELECT
    Person
WHERE
    ( (country NOT LIKE '%France%' AND country NOT LIKE '%America%')
     OR country IS NULL
    )
  AND 
    ( (region NOT LIKE '%France%' AND region NOT LIKE '%America%')
     OR region IS NULL
    )