Skip to content
Think & Reflect · Q8

Q.What will happen if in the above query we write "Aaliya" as "AALIYA" or "aaliya" or "AaLIYA"? Will the query generate the same output or an error?

Uttar Pradesh UpmspTextbookSubjective· 2mImportance★★★★★est
98% · 44/45 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

The query will run without any error and — in MySQL's default setup — will produce the same output for "AALIYA", "aaliya" and "AaLIYA". String comparison in MySQL's default collations is case-insensitive, so all four spellings match the stored value Aaliya.

Try it and see

The original lookup:

SELECT * FROM STUDENT WHERE SName = 'Aaliya';

Now the three variations:

SELECT * FROM STUDENT WHERE SName = 'AALIYA';
SELECT * FROM STUDENT WHERE SName = 'aaliya';
SELECT * FROM STUDENT WHERE SName = 'AaLIYA';

Every one of them returns the same row:

RollNumberSNameClass
101Aaliya11

Why — two different kinds of "case" in SQL

  1. Keywords (SELECT, WHERE, ...) are always case-insensitive, so case can never cause a syntax error here.
  2. String values are compared according to the column's collation. MySQL's default collations end in _ci — case-insensitive (for example utf8mb4_0900_ai_ci). Under a _ci collation, 'AALIYA' = 'Aaliya' evaluates to true, so the WHERE clause selects the very same row each time. …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.