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
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:
| RollNumber | SName | Class |
|---|---|---|
| 101 | Aaliya | 11 |
Why — two different kinds of "case" in SQL
- Keywords (
SELECT,WHERE, ...) are always case-insensitive, so case can never cause a syntax error here. - String values are compared according to the column's collation. MySQL's default collations end in
_ci— case-insensitive (for exampleutf8mb4_0900_ai_ci). Under a_cicollation,'AALIYA' = 'Aaliya'evaluates to true, so theWHEREclause 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.