Given the following table:
Students
ID Name Marks 1. Alice 85 2. Bob 90 3. Charlie 75
Which query will return all students having 'li' substring in their Names?
Given the following table:
Students
| ID | Name | Marks |
|---|---|---|
| 1. | Alice | 85 |
| 2. | Bob | 90 |
| 3. | Charlie | 75 |
Which query will return all students having 'li' substring in their Names?
Solution
The LIKE operator matches patterns, and % stands for any number of characters (including none). The pattern '%li%' matches any name that contains "li" anywhere, so it returns both Alice and Charlie.
Option 1: = checks for an exact match, so only a name that is exactly "li" would match.
Option 3: '%li' matches only names that end with "li". Alice ends in "ce" and Charlie in "ie", so neither matches.
Option 4: 'li' has no wildcard, so it behaves like an exact match.
'li%' matches names that start with "li", and '%li' matches names that end with "li".
Related questions:
2026: 29 May Shift 1
2025: 20 May Shift 1
2026: 18 May Shift 2
2025: 21 May Shift 1