CBSE Class 12 Informatics Practices
Question 28 of 79
MySQL SQL Revision Tour — Question 21
Back to all questions 21
Question Mr. Mittal is using a table with following columns :
Name, Class, Stream_Id, Stream_name
He needs to display names of students who have not been assigned any stream or have been assigned stream_name that ends with "computers".
He wrote the following command, which did not give the desired result.
SELECT Name, Class FROM Students
WHERE Stream_name = NULL OR Stream_name = "%computers" ;
Help Mr. Mittal to run the query by removing the error and write correct query.
The error in Mr. Mittal's original query lies in using "= NULL" instead of "IS NULL" to check for NULL values and using = '%computers' instead of "LIKE '%computers'" for pattern matching.
The correct query is:
SELECT Name
FROM Students
WHERE Stream_name IS NULL OR Stream_name LIKE '%computers';