I’m confused with one of the questions in the Codecademy Learners Mockup Data project. There is a column in the database called mobile_app, which contains either the entry NULL or 'mobile-user'. The task is simply to count all the rows that contain 'mobile-user'. I tried this 2 different ways. The first time I used a the = operator in my WHERE clause to count all the entries where mobile_app equals ‘mobile-user’. This gave me the correct answer.

FROM `users`
WHERE `mobile_app` = 'mobile-user';

However, I also tried the query using WHERE mobile_app IS NOT NULL. This returned the count of all rows in the table, rather than only the ones that contained ‘mobile-user’.
I also tried `WHERE NOT mobile_app = ‘NULL’" and variations thereof, to no avail.

Could someone please explain this for me?

When you write


you are effectively saying where there is any value in the column, show the number of those columns. In your case, you wanted find the columns where the only data was 'mobile-user'. Therefore, you can only use the query where you specify this.

I hope this has helped you!
Happy coding!

1 Like