Table Student(name) has rows ‘amir’, ‘asma’, ‘bilal’, ‘sana’ and ‘aamna’. SELECT COUNT(*) FROM Student WHERE name LIKE ‘a_m%’; What is the result?
Correct answer C. 2
Explanation
In LIKE, the underscore matches exactly one character and % matches any sequence, including none. The pattern 'a_m%' needs 'a' first, any one character second and 'm' third. 'asma' (a, s, m) and 'aamna' (a, a, m) match. 'amir' fails because its third character is 'i'; the m in second place is used up by the underscore.
Answer checked How we write and check questions
Discussion