Which line of the following code has an error? SELECT * FROM emp WHERE comm = NULL ORDER BY ename;

  1. SELECT *

  2. FROM emp

  3. WHERE comm = NULL

  4. There is no error in this statement.


Correct Option: D

AI Explanation

To answer this question, we need to analyze each line of the code to identify any errors:

A. SELECT * This line is correct. It specifies that all columns should be selected from the table.

B. FROM emp This line is correct. It specifies the table name "emp" from which the data should be retrieved.

C. WHERE comm = NULL This line has an error. In SQL, you cannot compare a value to NULL using the "=" operator. Instead, you should use the "IS NULL" operator to check for NULL values. The correct syntax should be: WHERE comm IS NULL

D. There is no error in this statement. This is the correct answer. The only error in the code is on line C, where the comparison operator should be "IS NULL" instead of "=".

Therefore, the correct answer is D.

Find more quizzes: