MySQL String Functions: 100 MCQ Practice Set

 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)

  1. Which function converts 'C++' to 'c++'?

    • A) LOWER() | B) UCASE() | C) SMALL() | D) MIN()

  2. What is the output of SELECT LENGTH('SQL Server');?

    • A) 9 | B) 10 | C) 11 | D) 8

  3. In MySQL, the index of the first character in a string is:

    • A) 0 | B) 1 | C) -1 | D) Depends on settings

  4. SELECT LCASE('Class XII'); returns:

    • A) CLASS XII | B) class xii | C) Class | D) xii

  5. Which function is a synonym for UPPER()?

    • A) CAPS() | B) UCASE() | C) TOP() | D) BIG()

  6. SELECT LENGTH(' Hi '); returns:

    • A) 2 | B) 4 | C) 6 | D) 0

  7. Output of SELECT UPPER(LOWER('MySQL'));?

    • A) mysql | B) MySQL | C) MYSQL | D) MySql

  8. 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)

  1. What is SELECT LEFT('Computer', 3);?

    • A) ter | B) put | C) Com | D) mpu

  2. What is SELECT RIGHT('Informatics', 4);?

    • A) Info | B) tics | C) matics | D) rmat

  3. SELECT SUBSTR('Database', 3, 4); returns:

    • A) Data | B) taba | C) abas | D) base

  4. Which function is identical to SUBSTR()?

    • A) MID() | B) MIDDLE() | C) PART() | D) SECTION()

  5. Output of SELECT SUBSTR('Informatics', 5); (without length parameter)?

    • A) Infor | B) matics | C) rmatics | D) Info

  6. SELECT RIGHT('CBSE', 10); (length greater than string) returns:

    • A) NULL | B) Error | C) CBSE | D) Spaces

  7. SELECT LEFT('Science', 0); returns:

    • A) S | B) NULL | C) Empty String | D) Error


Section 3: Search & Clean - INSTR, TRIM (Questions 56-80)

  1. What is the output of SELECT INSTR('CBSE BOARD', 'A');?

    • A) 8 | B) 7 | C) 9 | D) 0

  2. SELECT INSTR('Programming', 'z'); returns:

    • A) NULL | B) Error | C) 0 | D) -1

  3. SELECT TRIM(' Python '); returns:

    • A) ' Python' | B) 'Python ' | C) 'Python' | D) 'P y t h o n'

  4. Which function removes only leading spaces?

    • A) LTRIM() | B) RTRIM() | C) TRIM() | D) LEFTTRIM()

  5. SELECT INSTR('INDIA', 'I'); (first occurrence) returns:

    • A) 1 | B) 4 | C) 5 | D) 0

  6. SELECT LENGTH(RTRIM('Exam ')); returns:

    • A) 7 | B) 4 | C) 3 | D) 0


Section 4: Nested & Logical (Questions 81-100)

  1. SELECT UPPER(RIGHT('paper', 2));

    • A) PA | B) ER | C) RE | D) ER

  2. SELECT SUBSTR(LOWER('HELLO'), 2, 2);

    • A) EL | B) el | C) HE | D) he

  3. SELECT LENGTH(LTRIM(' XII '));

    • A) 3 | B) 6 | C) 9 | D) 0

  4. SELECT CONCAT(LEFT('Delhi', 2), RIGHT('Mumbai', 2));

    • A) Deai | B) Demu | C) Diai | D) Delmu

  5. SELECT INSTR(UPPER('exam'), 'X');

    • A) 1 | B) 2 | C) 3 | D) 0

  6. What happens if SUBSTR start position is negative?

    • A) Returns Error | B) Starts from the end of string | C) Returns NULL | D) Ignored


Answer Key (Quick Reference)

RangeCore ConceptLogic Note
1-25BasicCase functions only affect letters; LENGTH counts spaces too.
26-55SlicingImportant: MySQL starts at 1. SUBSTR(str, start, length).
56-80SearchingINSTR returns 0 if not found; TRIM cleans the edges.
81-100CombinedAlways solve the innermost function first!

Key Logic Table for Exam Prep:

FunctionExampleResultWhy?
INSTRINSTR('KV', 'V')2'V' is the 2nd letter.
SUBSTRSUBSTR('KV', 2, 1)'V'Start at 2, take 1 char.
MIDMID('KV', 1, 1)'K'Same as SUBSTR.
TRIMTRIM(' 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#AnswerLogic
87CUPPER 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'.
88AMost MySQL installations are case-insensitive for searches.
89B' XII ' has 1 space + 3 letters + 1 space = 5 characters.
90CLOWER makes 'hi', UPPER makes 'HI', CONCAT joins them.
91BLength in string functions must be positive.
92CLength 0 means no characters are extracted.
93COrder of TRIM and UPPER doesn't change the final clean uppercase result.
94ASUBSTR(..., 5) starts at 'B' $\rightarrow$ 'BASE'. LENGTH('BASE') is 4.
96BREVERSE() is a standard string function.
97BSpace counts as a character.
99CSUM, 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).

Post a Comment

Please do note create link post in comment section

Previous Post Next Post