Which of the following MySQL query will display all the NAME from the table…

2023

Which of the following MySQL query will display all the NAME from the table STUDENT, which are having maximum five characters and starting with the alphabet ‘A’?

  1. A.

    SELECT NAME FROM STUDENT

    WHERE NAME LIKE 'A____';

  2. B.

    SELECT NAME FROM STUDENT

    WHERE NAME = 'A____';

  3. C.

    SELECT NAME FROM STUDENT

    WHERE NAME = 'A%%%%%';

  4. D.

    SELECT NAME FROM STUDENT

    WHERE NAME LIKE 'A%%%%%';

Attempted by 1707 students.

Show answer & explanation

Correct answer: A

In MySQL, _ represents exactly one character. 'A____' means A + 4 characters = total 5 characters, starting with A.

The pattern 'A____' matches names that are exactly five characters long and start with 'A'.

If a query needs to match names that have a maximum of five characters (meaning 1, 2, 3, 4, or 5 characters), none of the standard multiple-choice options perfectly capture that standard SQL behavior on their own without functions (like LENGTH(NAME) <= 5). However, among the choices provided in standard exam questions of this type, Option 1 is the only one that uses the correct wildcard syntax (LIKE and _) to restrict character lengths.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Up Lt Grade Assistant Teacher 2025