What will the following query retrieve?
SELECT MID(phone, 3, 4) from customer where cust_address like '%Rohini%';
What will the following query retrieve?
SELECT MID(phone, 3, 4) from customer where cust_address like '%Rohini%';
Solution
✅ Correct Option: 1
MID(string, start, length) returns length characters beginning at position start. So MID(phone, 3, 4) gives 4 characters starting from position 3 of the phone column.
In LIKE '%Rohini%', the % on both sides matches any characters, so the condition selects customers whose address contains "Rohini" anywhere in it.
Option 2: swaps the start and length arguments, since 3 is the start and 4 is the length.
Options 3 and 4: "starts with" would need 'Rohini%', and "ends with" would need '%Rohini'.
Related questions:
2025: 14 May Shift 1
2026: 24 May Shift 1
2025: 3 June Shift 2