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
'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.
SELECT COUNT(*) 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?