0% found this document useful (0 votes)
3 views

mysql-output-related-questions-12

The document provides a series of MySQL queries along with their expected outputs, covering string, numeric, and date/time functions. It lists various MySQL functions such as CONCAT, LOWER, UPPER, MOD, POWER, CURDATE, and others, explaining their purposes. Additionally, it includes a section comparing CURDATE() and DATE() functions.

Uploaded by

Kanchan Behal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

mysql-output-related-questions-12

The document provides a series of MySQL queries along with their expected outputs, covering string, numeric, and date/time functions. It lists various MySQL functions such as CONCAT, LOWER, UPPER, MOD, POWER, CURDATE, and others, explaining their purposes. Additionally, it includes a section comparing CURDATE() and DATE() functions.

Uploaded by

Kanchan Behal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

MYSQL OUTPUT RELATED QUESTIONS

Give the output of the following queries:

i) SELECT CONCAT(‘ABC’,’XYZ’) ;
O/P  ‘ABCXYZ’
ii) SELECT LOWER(‘INFORMATICS PRACTICES’);
O/P informatics practices
iii) SELECT SUBSTR(‘ABCDEFG’,3,4);
O/P CDEF
iv) SELECT SUBSTR(‘ABCDEFG’,-5,4);
O/P CDEF (Access 5th character from right side and extracts 4 character)
v) SELECT UPPER(‘ip’);
O/P IP
vi) SELECT LTRIM(‘ RDBMS MySQL’);
O/P ‘RDBMS MySQL’
vii) SELECT RTRIM(‘RDMBS MySQL ‘);
O/P ‘RDBMS MySQL’
viii) SELECT INSTR(‘CORPORATE FLOOR’,’OR’);

O/P 2 (Prints first occurrence of substring OR in main string


CORPORATE FLOOR

ix) SEELCT LENGTH(‘ABCDEF GH’);


O/P 8
x) SELECT LEFT(‘ABCDEFGH’,3);
O/P ‘ABC’
xi) SELECT RIGHT(‘ABCDEFG’,2);
O/P ‘FG’
xii) SELECT MOD(11,4);
O/P 3
xiii) SELECT POWER(3,2);
O/P 9
xiv) SELECT ROUND(15.193,1);
O/P 15.2
xv) SELECT TRUNCATE(15.193,1);
O/P  15.1
xvi) SELECT SQRT(25);
O/P  5
xvii) SELECT CURDATE( );

O/P 
xviii) SELECT DATE (‘2016-11-25 01:02:30’);
o/p
xix) SELECT MONTH(‘2016-11-25’);
O/P 11
xx) SELECT YEAR(‘2016-11-25’);
O/P 2016
xxi) SELECT DAYNAM E(‘2016-11-25’);

O/P
xxii) SELECT DAYOFMONTH(‘2016-11-25’);
O/P25
xxiii) SELECT DAYOFWEEK(‘2016-11-25’);

O/P

xxiv) SELECT DAYOFYEAR(‘2016-11-25’);

O/P
xxv) SELECT NOW();

O/P
xxvi) SELECT SYSDATE();
Name different String Functions of MySQL:

i) CHAR( )  returns character for each integer passed


ii) CONCAT( ) returns concatenated String
iii) LOWER()/LCASE()  returns the string in lowercase
iv) UPPER()/UCASE() returns the string in upper case
v) SUBSTRING()/SUBSTR() returns the substring from main string
vi) LTRIM( ) returns string after removing leading spaces
vii) RTRIM( ) returns a string after removing trailing spaces
viii) TRIM( ) returns a string after removing leading and trailing spaces
ix) INSTR( ) returns the index of the first occurrence of substring
x) LENGTH( ) returns the length of a string in bytes
xi) LEFT( ) returns the leftmost number of characters as specified
xii) RIGTH( ) returns the rightmost number of characters as specified
xiii) MID( ) returns the substring from a starting position to ending position
Name different Numeric Functions Of MySQL:

i) MOD( ) returns the remainder of one expression by dividing by another expressions


ii) POWER( )/POW( ) returns the value of one expression raised to the power of another
expression
iii) ROUND( )  returns the numeric expression rounded to an integer
iv) SIGN( )  returns sign of a given number
v) SQRT( ) returns square root of passed no
vi) TRUNCATE( ) returns exp1 truncated to exp2
Write different DATA and TIME functions Of MySQL:

i) CURDATE( )  returns current date


ii) DATE( )  extract date part of a date and time expression
iii) MONTH ( ) returns the month from the date passed
iv) YEAR( ) returns the year
v) DAYNAME( ) returns the name of the weekday
vi) DAYOFMONTH( )  returns the day no of the month (1-31)
vii) DAYOFWEEK( )  returns day no of week(1-7)
viii) NOW( )  returns date and time
ix) SYSDATE( )  returns date and time at which time function executes

Write the output of the following queries:

(i) SELECT ROUND(6.5675,2);


(ii) SELECT TRUNCATE(5.3456,1);
(iii) SELECT DAYOFMONTH(‘2009-08-25’);
(iv) SELECT MID(‘Class 12’,2,3);

OUTPUT:

(i) 6.57
(ii) 5.3
(iii) 25
(iv) Las

What is the difference between CURDATE () and DATE () functions?

You might also like