CBSE Class 12 Informatics Practices Question 30 of 79

MySQL SQL Revision Tour — Question 23

Back to all questions
23
Question

Question 19

Sarthak, a student of class XII, created a table "Class". Grade is one of the columns of this table. To find the details of students whose Grades have not been entered, he wrote the following MySql query, which did not give the desired result:

SELECT * FROM Class WHERE Grade = "Null";

Help Sarthak to run the query by removing the errors from the query and write the correct query.

Answer

The error in Sarthak's code is that he should use the IS NULL comparison instead of = "Null" because the correct syntax to check for NULL values in SQL is to use the IS NULL operator.

The correct query is:

SELECT * FROM Class WHERE Grade IS NULL;