CBSE Class 12 Informatics Practices Question 69 of 81

MySQL Functions — Question 20

Back to all questions
20
Question

Question 12

Write the SQL functions which will perform the following operations :

(i) To display the name of the month of the current date.

(ii) To remove spaces from the beginning and end of a string, "Panorama".

(iii) To display the name of the day e.g., Friday or Sunday from your date of birth, dob.

(iv) To display the starting position of your first name(fname) from your whole name (name).

(v) To compute the remainder of division between two numbers, n1 and n2.

Answer

(i)

SELECT MONTHNAME(CURDATE());
Output
+----------------------+
| MONTHNAME(CURDATE()) |
+----------------------+
| May                  |
+----------------------+

(ii)

SELECT TRIM("  Panorama  ");
Output
+----------------------+
| TRIM("  Panorama  ") |
+----------------------+
| Panorama             |
+----------------------+

(iii)

SELECT DAYNAME('2000-07-22');
Output
+-----------------------+
| DAYNAME('2000-07-22') |
+-----------------------+
| Saturday              |
+-----------------------+

(iv)

SELECT INSTR('Gupta Ashwini', 'Ashwini') AS StartingPosition;
Output
+------------------+
| StartingPosition |
+------------------+
|                7 |
+------------------+

(v)

SELECT MOD(n1, n2);