arrow
arrow
arrow
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 al
Question

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’?

A.

SELECT NAME FROM STUDENT WHERE NAME LIKE 'A_ _ _ _';

B.

SELECT NAME FROM STUDENT WHERE NAME = 'A_ _ _';

C.

SELECT NAME FROM STUDENT WHERE NAME = 'A%%%%';

D.

SELECT NAME FROM STUDENT WHERE NAME LIKE 'A%%%%';

Correct option is A


The correct query to display all the NAME values from the STUDENT table, which have a maximum of five characters and start with the alphabet 'A', is:
SELECT NAME FROM STUDENT WHERE NAME LIKE 'A_ _ _ _';
· LIKE 'A_ _ _ _': In the LIKE pattern, the first character 'A' ensures that the name starts with 'A'. The underscores (_) are wildcard characters that match exactly one character. So, the pattern 'A_ _ _ _' matches strings that start with 'A' and are exactly five characters long.
Important Key Points:
1. LIKE: The LIKE operator is used to search for a pattern in a column.
2. Underscore (_): Each underscore in the pattern represents exactly one character.
3. Exact Length Matching: The pattern 'A_ _ _ _' will match strings that have exactly five characters, starting with 'A'.
Knowledge Booster:
· Option (b): NAME = 'A_ _ _' is incorrect because = is used for exact string matching, and it cannot match the pattern with multiple characters (as the underscores would indicate). Also, this pattern would only match strings that have exactly four characters, not five.
· Option (c): NAME = 'A%%%%' is incorrect because = does not allow the use of multiple wildcard characters (percent signs %%). The percent sign is used with LIKE, not with =. This pattern would not match the correct strings either.
· Option (d): NAME LIKE 'A%%%%' is incorrect because %% is used as a wildcard to match any number of characters (including zero). This pattern would match strings starting with 'A' of any length, not exactly five characters long.

Free Tests

Free
Must Attempt

UPTET Paper 1: PYP Held on 23rd Jan 2022 (Shift 1)

languageIcon English
  • pdpQsnIcon150 Questions
  • pdpsheetsIcon150 Marks
  • timerIcon150 Mins
languageIcon English
Free
Must Attempt

UPTET Paper 2 Social Science : PYP Held on 23rd Jan 2022 (Shift 2)

languageIcon English
  • pdpQsnIcon150 Questions
  • pdpsheetsIcon150 Marks
  • timerIcon150 Mins
languageIcon English
Free
Must Attempt

UPTET Paper 2 Maths & Science : PYP Held on 23rd Jan 2022 (Shift 2)

languageIcon English
  • pdpQsnIcon150 Questions
  • pdpsheetsIcon150 Marks
  • timerIcon150 Mins
languageIcon English
test-prime-package

Access ‘EMRS PGT’ Mock Tests with

  • 60000+ Mocks and Previous Year Papers
  • Unlimited Re-Attempts
  • Personalised Report Card
  • 500% Refund on Final Selection
  • Largest Community
students-icon
353k+ students have already unlocked exclusive benefits with Test Prime!
Our Plans
Monthsup-arrow