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)

Go Ad-free

Transcript

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)

Davneet Singh's photo - Co-founder, Teachoo

Made by

Davneet Singh

Davneet Singh has done his B.Tech from Indian Institute of Technology, Kanpur. He has been teaching from the past 14 years. He provides courses for Maths, Science and Computer Science at Teachoo