Which of the following statements is appropriate to display roll Number and names of all students that belongs to any section of class 11?
(A) SELECT roll_no, name FROM student WHERE class LIKE ‘11’
(B) SELECT roll_no, name FROM student WHERE class LIKE ‘11%’
(C) SELECT roll_no, name FROM student WHERE class LIKE ‘11_’
(D) SELECT roll_no, name FROM student WHERE class NOT LIKE ‘11’
Answer:
To display roll Number and names of all students that belong to any section of class 11, the
LIKE operator
followed by the
pattern for matching
should be added to the
WHERE clause
of the query.
There are 2 wildcards that are used while mentioning the patterns in conjunction to the LIKE operator:
Wildcard
Description
% (percentage symbol)
Represents zero, one, or multiple characters
_ (underscore symbol)
Represents one single character
Since sections of a class are single characters, the
underscore symbol ( _ )
will be used
after 11
in the pattern for searching.
Checking the options
(A) SELECT roll_no, name FROM student WHERE class LIKE ‘11’ -
The pattern mentioned is incorrect.
(B) SELECT roll_no, name FROM student WHERE class LIKE ‘11%’ -
The pattern mentioned is incorrect.
(C) SELECT roll_no, name FROM student WHERE class LIKE ‘11_’ -
The pattern mentioned is
correct.
(D) SELECT roll_no, name FROM student WHERE class NOT LIKE ‘11’ -
The syntax is incorrect.
Which of the following statements is appropriate to display roll Number and names of all students that belongs to any section of class 11?
(A) SELECT roll_no, name FROM student WHERE class LIKE ‘11’
(B) SELECT roll_no, name FROM student WHERE class LIKE ‘11%’
(C) SELECT roll_no, name FROM student WHERE class LIKE ‘11_’
(D) SELECT roll_no, name FROM student WHERE class NOT LIKE ‘11’
Answer:
To display roll Number and names of all students that belong to any section of class 11, the LIKE operator followed by the pattern for matching should be added to the WHERE clause of the query.
There are 2 wildcards that are used while mentioning the patterns in conjunction to the LIKE operator:
Wildcard
Description
% (percentage symbol)
Represents zero, one, or multiple characters
_ (underscore symbol)
Represents one single character
Since sections of a class are single characters, the underscore symbol ( _ ) will be used after 11 in the pattern for searching.
Checking the options
(A) SELECT roll_no, name FROM student WHERE class LIKE ‘11’ - The pattern mentioned is incorrect.
(B) SELECT roll_no, name FROM student WHERE class LIKE ‘11%’ - The pattern mentioned is incorrect.
(C) SELECT roll_no, name FROM student WHERE class LIKE ‘11_’ - The pattern mentioned is correct.
(D) SELECT roll_no, name FROM student WHERE class NOT LIKE ‘11’ - The syntax is incorrect.
So, the correct answer is (C)
Made by
Davneet Singh
Davneet Singh is an IIT Kanpur graduate and has been teaching for 16+ years. At Teachoo, he breaks down Maths, Science and Computer Science into simple steps so students understand concepts deeply and score with confidence.
Many students prefer Teachoo Black for a smooth, ad-free learning experience.
It looks like you're using AdBlock
Don't be a miser! Join Teachoo Black at ₹19 only to view the ad-free version of Teachoo.
Please login to view more pages. It's free :)
Teachoo gives you a better experience when you're logged in. Please login :)