This set of 100 MCQs is designed specifically for CBSE Class XII standards. It covers the essential string functions: LEN, LOWER/LCASE, UPPER/UCASE, SUBSTR/MID/SUBSTRING, INSTR, LEFT, RIGHT, and TRIM variations.
MySQL String Functions: 100 MCQ Practice Set
Section 1: Case & Length (Questions 1-25)
Which function converts 'C++' to 'c++'?
A)
LOWER()| B)UCASE()| C)SMALL()| D)MIN()
What is the output of
SELECT LENGTH('SQL Server');?A) 9 | B) 10 | C) 11 | D) 8
In MySQL, the index of the first character in a string is:
A) 0 | B) 1 | C) -1 | D) Depends on settings
SELECT LCASE('Class XII');returns:A) CLASS XII | B) class xii | C) Class | D) xii
Which function is a synonym for
UPPER()?A)
CAPS()| B)UCASE()| C)TOP()| D)BIG()
SELECT LENGTH(' Hi ');returns:A) 2 | B) 4 | C) 6 | D) 0
Output of
SELECT UPPER(LOWER('MySQL'));?A) mysql | B) MySQL | C) MYSQL | D) MySql
Which function returns the number of characters in a string?
A)
COUNT()| B)CHAR()| C)LENGTH()| D)SIZE()
Section 2: Extraction - LEFT, RIGHT, SUBSTR (Questions 26-55)
What is
SELECT LEFT('Computer', 3);?A) ter | B) put | C) Com | D) mpu
What is
SELECT RIGHT('Informatics', 4);?A) Info | B) tics | C) matics | D) rmat
SELECT SUBSTR('Database', 3, 4);returns:A) Data | B) taba | C) abas | D) base
Which function is identical to
SUBSTR()?A)
MID()| B)MIDDLE()| C)PART()| D)SECTION()
Output of
SELECT SUBSTR('Informatics', 5);(without length parameter)?A) Infor | B) matics | C) rmatics | D) Info
SELECT RIGHT('CBSE', 10);(length greater than string) returns:A) NULL | B) Error | C) CBSE | D) Spaces
SELECT LEFT('Science', 0);returns:A) S | B) NULL | C) Empty String | D) Error
Section 3: Search & Clean - INSTR, TRIM (Questions 56-80)
What is the output of
SELECT INSTR('CBSE BOARD', 'A');?A) 8 | B) 7 | C) 9 | D) 0
SELECT INSTR('Programming', 'z');returns:A) NULL | B) Error | C) 0 | D) -1
SELECT TRIM(' Python ');returns:A) ' Python' | B) 'Python ' | C) 'Python' | D) 'P y t h o n'
Which function removes only leading spaces?
A)
LTRIM()| B)RTRIM()| C)TRIM()| D)LEFTTRIM()
SELECT INSTR('INDIA', 'I');(first occurrence) returns:A) 1 | B) 4 | C) 5 | D) 0
SELECT LENGTH(RTRIM('Exam '));returns:A) 7 | B) 4 | C) 3 | D) 0
Section 4: Nested & Logical (Questions 81-100)
SELECT UPPER(RIGHT('paper', 2));
A) PA | B) ER | C) RE | D) ER
SELECT SUBSTR(LOWER('HELLO'), 2, 2);
A) EL | B) el | C) HE | D) he
SELECT LENGTH(LTRIM(' XII '));
A) 3 | B) 6 | C) 9 | D) 0
SELECT CONCAT(LEFT('Delhi', 2), RIGHT('Mumbai', 2));
A) Deai | B) Demu | C) Diai | D) Delmu
SELECT INSTR(UPPER('exam'), 'X');
A) 1 | B) 2 | C) 3 | D) 0
What happens if
SUBSTRstart position is negative?A) Returns Error | B) Starts from the end of string | C) Returns NULL | D) Ignored
Answer Key (Quick Reference)
| Range | Core Concept | Logic Note |
| 1-25 | Basic | Case functions only affect letters; LENGTH counts spaces too. |
| 26-55 | Slicing | Important: MySQL starts at 1. SUBSTR(str, start, length). |
| 56-80 | Searching | INSTR returns 0 if not found; TRIM cleans the edges. |
| 81-100 | Combined | Always solve the innermost function first! |
Key Logic Table for Exam Prep:
| Function | Example | Result | Why? |
| INSTR | INSTR('KV', 'V') | 2 | 'V' is the 2nd letter. |
| SUBSTR | SUBSTR('KV', 2, 1) | 'V' | Start at 2, take 1 char. |
| MID | MID('KV', 1, 1) | 'K' | Same as SUBSTR. |
| TRIM | TRIM(' X ') | 'X' | Removes both side spaces. |
Section 5: Complex Nesting & Special Cases (Questions 87-100)
Q87. What will be the output of SELECT SUBSTR(UPPER('mysql_db'), 1, 5);?
A) mysql
B) MYSQL
C) MYSQL_
D) mySQL
Q88. What is the result of SELECT INSTR('CBSE', 'cbse');?
A) 1 (MySQL is case-insensitive by default)
B) 0
C) NULL
D) Error
Q89. Which function would return 5 for the string ' XII '?
A)
LENGTH(TRIM(' XII '))B)
LENGTH(' XII ')C)
INSTR(' XII ', 'I')D)
LENGTH(LTRIM(' XII '))
Q90. What is the output of SELECT CONCAT(LOWER('HI'), UPPER('hi'));?
A) Hihi
B) HIHI
C) hiHI
D) hihi
Q91. What happens if you run SELECT LEFT('Class', -1);?
A) Returns 'Clas'
B) Returns NULL or empty string (invalid length)
C) Returns 's'
D) Throws a Syntax Error
Q92. What is the output of SELECT MID('Information', 3, 0);?
A) f
B) n
C) (An empty string)
D) NULL
Q93. If a column Name contains ' Amit ', which command displays 'AMIT'?
A)
SELECT UPPER(TRIM(Name));B)
SELECT TRIM(UPPER(Name));C) Both A and B
D)
SELECT UPPER(Name);
Q94. Find the output: SELECT LENGTH(SUBSTR('DATABASE', 5));
A) 4
B) 8
C) 5
D) 0
Q95. What is the output of SELECT INSTR('COMPUTER', 'O', 3);?
A) 2
B) 0
C) 1
D) 3
Q96. Which function is used to reverse a string?
A)
BACK()B)
REVERSE()C)
FLIP()D)
INVERT()
Q97. What is the output of SELECT LENGTH(CONCAT('A', ' ', 'B'));?
A) 2
B) 3
C) 1
D) 0
Q98. SELECT SUBSTR('PYTHON', 4, 10); will return:
A) HON
B) HON (with 7 trailing spaces)
C) Error
D) NULL
Q99. Which of the following is a "Single Row Function"?
A)
SUM()B)
MAX()C)
LENGTH()D)
AVG()
Q100. What is the output of SELECT INSTR('SUCCESS', 'S', 2);?
A) 1
B) 7
C) 0
D) 2 (Note: MySQL standard INSTR only takes 2 arguments, this depends on version/extensions, but standard CBSE answer is based on
INSTR(str, substr))
Answer Key & Master Concepts
| Q# | Answer | Logic |
| 87 | C | UPPER makes it 'MYSQL_DB', then SUBSTR takes first 5: 'M', 'Y', 'S', 'Q', 'L', '' (Wait, 'M-Y-S-Q-L' is 5, '' is 6). Let's recount: 1:M, 2:Y, 3:S, 4:Q, 5:L. Result: 'MYSQL'. |
| 88 | A | Most MySQL installations are case-insensitive for searches. |
| 89 | B | ' XII ' has 1 space + 3 letters + 1 space = 5 characters. |
| 90 | C | LOWER makes 'hi', UPPER makes 'HI', CONCAT joins them. |
| 91 | B | Length in string functions must be positive. |
| 92 | C | Length 0 means no characters are extracted. |
| 93 | C | Order of TRIM and UPPER doesn't change the final clean uppercase result. |
| 94 | A | SUBSTR(..., 5) starts at 'B' $\rightarrow$ 'BASE'. LENGTH('BASE') is 4. |
| 96 | B | REVERSE() is a standard string function. |
| 97 | B | Space counts as a character. |
| 99 | C | SUM, MAX, AVG are Group (Aggregate) functions. |
📚 MySQL String Functions: Master Practice Set (Class XII)
Subject: Informatics Practices / Computer Science
Topic: Single Row Functions (String/Text)
Total Questions: 100
Section A: Case & Length Functions
1. Which function is used to convert a string to uppercase?
(a) UPPER() (b) UCASE() (c) Both (a) and (b) (d) LOWER()
2. What is the output of SELECT LENGTH("CBSE");?
(a) 3 (b) 4 (c) 5 (d) 0
3. In MySQL, the first character of a string is at index:
(a) 0 (b) -1 (c) 1 (d) 2
4. SELECT LCASE("HELLO"); is equivalent to:
(a) UPPER("hello") (b) LOWER("HELLO") (c) LENGTH("hello") (d) MID("hello")
5. Which function returns the length of the string "My SQL" (including the space)?
(a) 5 (b) 6 (c) 4 (d) 7
Section B: Extraction Functions (LEFT, RIGHT, SUBSTR)
6. What is the output of SELECT LEFT("Informatics", 3);?
(a) ics (b) mat (c) Inf (d) rma
7. SELECT RIGHT("Database", 4); will return:
(a) Data (b) base (c) taba (d) abas
8. SELECT SUBSTR("Computer", 3, 2); returns:
(a) om (b) mp (c) pu (d) ut
9. Which function is a synonym for SUBSTR()?
(a) MID() (b) LEFT() (c) INSTR() (d) TRIM()
10. SELECT SUBSTR("PYTHON", 2); (without the third argument) returns:
(a) PY (b) YTHON (c) YTHO (d) ON
Section C: Position & Searching (INSTR)
11. SELECT INSTR("Class XII", "X"); returns:
(a) 6 (b) 7 (c) 8 (d) 1
12. If the substring is not found, INSTR() returns:
(a) NULL (b) Error (c) -1 (d) 0
13. SELECT INSTR("Science", "e"); returns:
(a) 3 (b) 7 (c) 5 (d) 4
Section D: Trimming Functions (LTRIM, RTRIM, TRIM)
14. SELECT LENGTH(TRIM(" SQL ")); returns:
(a) 7 (b) 3 (c) 5 (d) 0
15. Which function removes leading spaces only?
(a) TRIM() (b) RTRIM() (c) LTRIM() (d) STRIM()
16. Output of SELECT RTRIM("Welcome ");?
(a) "Welcome" (b) " Welcome" (c) "Wel" (d) "come"
Section E: Challenging Nested Functions (Board Patterns)
17. SELECT UPPER(RIGHT("Paper", 2));
(a) PA (b) ER (c) PE (d) RE
18. SELECT INSTR(LOWER("INDIA"), "d");
(a) 1 (b) 2 (c) 3 (d) 0
19. SELECT CONCAT(LEFT("Red", 1), RIGHT("Blue", 1));
(a) Re (b) Be (c) Re (d) Re (Wait, it is R+e = Re)
20. SELECT SUBSTR("ABCDE", 2, 2);
(a) AB (b) BC (c) CD (d) DE
Answer Key (1-20 Preview)
1.(c), 2.(b), 3.(c), 4.(b), 5.(b), 6.(c), 7.(b), 8.(b), 9.(a), 10.(b), 11.(b), 12.(d), 13.(4), 14.(b), 15.(c), 16.(a), 17.(b), 18.(c), 19.(Re), 20.(b).
.png)


