Practice mode DBMS and SQL

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.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.