0% found this document useful (0 votes)
6 views5 pages

SQL Func

Uploaded by

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

SQL Func

Uploaded by

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

Enter password: ****

Welcome to the MySQL monitor. Commands end with ; or \g.


Your MySQL connection id is 2
Server version: 5.5.46 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its


affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select pow(4,-2);


+-----------+
| pow(4,-2) |
+-----------+
| 0.0625 |
+-----------+
1 row in set (0.00 sec)

mysql> select round(15.6485,2);


+------------------+
| round(15.6485,2) |
+------------------+
| 15.65 |
+------------------+
1 row in set (0.00 sec)

mysql> select round(15.6485,1);


+------------------+
| round(15.6485,1) |
+------------------+
| 15.6 |
+------------------+
1 row in set (0.00 sec)

mysql> select round (15.49,0);


+-----------------+
| round (15.49,0) |
+-----------------+
| 15 |
+-----------------+
1 row in set (0.00 sec)

mysql> select round (15.47382,3);


+--------------------+
| round (15.47382,3) |
+--------------------+
| 15.474 |
+--------------------+
1 row in set (0.00 sec)

mysql> select round (27548.648,-3);


+----------------------+
| round (27548.648,-3) |
+----------------------+
| 28000 |
+----------------------+
1 row in set (0.00 sec)

mysql> select round (27548.648,-3);


+----------------------+
| round (27548.648,-3) |
+----------------------+
| 28000 |
+----------------------+
1 row in set (0.00 sec)

mysql> select round (27548.648,-2);


+----------------------+
| round (27548.648,-2) |
+----------------------+
| 27500 |
+----------------------+
1 row in set (0.00 sec)

mysql> select round (27548.648,-5);


+----------------------+
| round (27548.648,-5) |
+----------------------+
| 0 |
+----------------------+
1 row in set (0.00 sec)

mysql> select round (67548.648,-5);


+----------------------+
| round (67548.648,-5) |
+----------------------+
| 100000 |
+----------------------+
1 row in set (0.00 sec)

mysql> select length("d.k. sharma");


+-----------------------+
| length("d.k. sharma") |
+-----------------------+
| 11 |
+-----------------------+
1 row in set (0.00 sec)

mysql> select* from product;


ERROR 1046 (3D000): No database selected
mysql> use product;
ERROR 1049 (42000): Unknown database 'product'
mysql> use office;
Database changed
mysql> select* from emp;
+-------+--------+------------+---------+--------+------+
| empid | ename | doj | city | salary | comm |
+-------+--------+------------+---------+--------+------+
| 1012 | Kartik | 2014-01-31 | Mumbai | 48960 | NULL |
| 1013 | Dhruv | 2010-07-22 | Kolkata | 45900 | 2400 |
| 1014 | Shreya | 2015-10-20 | Delhi | 29580 | 1200 |
| 1015 | Mansi | 2014-02-05 | Chennai | 36720 | NULL |
| 1017 | Shilpa | 2012-04-12 | Mumbai | 25500 | NULL |
| 1018 | Rohit | 2016-11-15 | Delhi | 47940 | 1400 |
| 1019 | Paul | 2014-06-08 | Chennai | 44880 | NULL |
| 1020 | Gloria | 2015-03-18 | Delhi | 61200 | 0 |
+-------+--------+------------+---------+--------+------+
8 rows in set (0.01 sec)

mysql> select length(ename) from emp;


+---------------+
| length(ename) |
+---------------+
| 6 |
| 5 |
| 6 |
| 5 |
| 6 |
| 5 |
| 4 |
| 6 |
+---------------+
8 rows in set (0.00 sec)

mysql> select ename,length(ename) from emp;


+--------+---------------+
| ename | length(ename) |
+--------+---------------+
| Kartik | 6 |
| Dhruv | 5 |
| Shreya | 6 |
| Mansi | 5 |
| Shilpa | 6 |
| Rohit | 5 |
| Paul | 4 |
| Gloria | 6 |
+--------+---------------+
8 rows in set (0.00 sec)

mysql> select char(68);


+----------+
| char(68) |
+----------+
| D |
+----------+
1 row in set (0.00 sec)

mysql> select char(70,97,99,101);


+--------------------+
| char(70,97,99,101) |
+--------------------+
| Face |
+--------------------+
1 row in set (0.00 sec)

mysql> select left("information",4


-> );
+------------------------+
| left("information",4
) |
+------------------------+
| info |
+------------------------+
1 row in set (0.00 sec)
mysql> select right("information",4);
+------------------------+
| right("information",4) |
+------------------------+
| tion |
+------------------------+
1 row in set (0.00 sec)

mysql> select right("ename",3) from emp;


+------------------+
| right("ename",3) |
+------------------+
| ame |
| ame |
| ame |
| ame |
| ame |
| ame |
| ame |
| ame |
+------------------+
8 rows in set (0.00 sec)

mysql> select right(ename,3) from emp;


+----------------+
| right(ename,3) |
+----------------+
| tik |
| ruv |
| eya |
| nsi |
| lpa |
| hit |
| aul |
| ria |
+----------------+
8 rows in set (0.00 sec)

mysql> select concat("hello",world);


ERROR 1054 (42S22): Unknown column 'world' in 'field list'
mysql> select concat("hello","world");
+-------------------------+
| concat("hello","world") |
+-------------------------+
| helloworld |
+-------------------------+
1 row in set (0.00 sec)

mysql> select concat("hello",ename) from emp;


+-----------------------+
| concat("hello",ename) |
+-----------------------+
| helloKartik |
| helloDhruv |
| helloShreya |
| helloMansi |
| helloShilpa |
| helloRohit |
| helloPaul |
| helloGloria |
+-----------------------+
8 rows in set (0.00 sec)

mysql> select concat("hello"," ",ename) from emp;


+---------------------------+
| concat("hello"," ",ename) |
+---------------------------+
| hello Kartik |
| hello Dhruv |
| hello Shreya |
| hello Mansi |
| hello Shilpa |
| hello Rohit |
| hello Paul |
| hello Gloria |
+---------------------------+
8 rows in set (0.00 sec)

mysql> select concat("hello ",ename) from emp;


+------------------------+
| concat("hello ",ename) |
+------------------------+
| hello Kartik |
| hello Dhruv |
| hello Shreya |
| hello Mansi |
| hello Shilpa |
| hello Rohit |
| hello Paul |
| hello Gloria |
+------------------------+
8 rows in set (0.00 sec)

mysql> select concat("hello"," ",ename) from emp;


+---------------------------+
| concat("hello"," ",ename) |
+---------------------------+
| hello Kartik |
| hello Dhruv |
| hello Shreya |
| hello Mansi |
| hello Shilpa |
| hello Rohit |
| hello Paul |
| hello Gloria |
+---------------------------+
8 rows in set (0.00 sec)

mysql>

You might also like