ryan
ryan

Reputation: 33

SQL query not achieveing conditionals

I am meant to display the name, population, continent, independence year and life expectancy in the countries query, where the Independence year is NULL, or the country is neither in Asia nor in Europe. It shows most of the countries but the ones that achieve the conditionals of being null and being in Asia or Europe are not shown.

SELECT Name, Population, Continent, IndepYear, LifeExpectancy 
FROM country 
WHERE  IndepYear = NULL OR Continent != "Asia" AND Continent != "Europe"; 

Upvotes: 1

Views: 103

Answers (1)

Gab
Gab

Reputation: 3520

If I understand your question correctly, you need:

SELECT Name, Population, Continent, IndepYear, LifeExpectancy 
FROM country 
WHERE  IndepYear IS NULL OR Continent NOT IN ('Asia', 'Europe'); 

Upvotes: 1

Related Questions