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?
[Context: the query referred to is Example 9.5 — mysql> SELECT * FROM EMPLOYEE WHERE NOT Ename = 'Aaliya';]
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 →SQL string comparisons are case-insensitive by default in MySQL (depending on the column's collation), so writing “AALIYA”, “aaliya”, or “AaLIYA” will produce the same output as the original query — no error, and the same rows excluded.
This question is about case sensitivity in SQL string comparisons — a concept that trips up many beginners. The core idea is that SQL's behaviour depends on the collation (the set of rules for comparing characters) of the column being queried.
In MySQL, the default character set and collation for string columns is typically utf8mb4 with utf8mb4_0900_ai_ci (or older versions use latin1_swedish_ci). The _ci suffix stands for case-insensitive. This means that when you compare two strings, MySQL treats uppercase and lowercase letters as equivalent — 'A' = 'a', 'B' = 'b', and so on.
So the original query:
SELECT * FROM EMPLOYEE WHERE NOT Ename = 'Aaliya';
...filters out all rows where Ename equals 'Aaliya' (case-insensitively). If you change the literal to 'AALIYA', 'aaliya', or 'AaLIYA', MySQL still performs the same case-insensitive comparison. It will match the same rows — those where Ename is 'Aaliya' (or any case variation of it, like 'AALIYA' or 'aaliya' if those values exist in the table). …
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.