Write the SQL statement for the query : “ Find the name of the students whose…
2023
Write the SQL statement for the query : “ Find the name of the students whose name contains letter ‘D’ .
- A.
Select name from student where name like ‘%D%’ ;
- B.
Select name from student where name like ‘%D’ ;
- C.
Select name from student where name like ‘D%’ ;
- D.
none of the above
Attempted by 824 students.
Show answer & explanation
Correct answer: A
Ans A
Solution
Pattern matching can be performed on strings, using the operator like.
Percent (%): The % character matches any substring.
Underscore ( ): The character matches any character.
For example:
’D%’ matches any string beginning with “D”.
’%D%’ matches any string containing “D” as a substring.
’_ _ _’ matches any string of exactly three characters.
’_ _ _%’ matches any string of at least three characters