您的位置:首页 > 数据库 > MySQL

mysql -查询练习2

2017-11-14 16:32 531 查看




select 18/5;

select 18%5;

select DEGREES(PI()/4);

select pow(9,4);

select round(3.14159,2);

select length("Hello World!");

select length("University");

select substring("nice to meet you",9,4);

select repeat("Cheer",3);

select reverse("voodoo");

select concat_ws(" ","MySql","is","great");

select week('2017-11-13',1);

select dayofweek('2017-11-14');

select timestampdiff(year,'1929-02-14','2017-11-14');

select date_format('2017-11-14','%y %a %D %W');

select second(curtime());

show processlist;

select encode("mysql","ha");

select decode(encode("mysql","ha"),"ha");

SELECT HEX(100);

select format("5.1584",3);

select convert("new string" using "gb2312");

mysql> select 18/5;
+--------+
| 18/5   |
+--------+
| 3.6000 |
+--------+
1 row in set (0.00 sec)

mysql> select 18%5;
+------+
| 18%5 |
+------+
|    3 |
+------+
1 row in set (0.00 sec)

mysql> select DEGREES(PI()/4);
+-----------------+
| DEGREES(PI()/4) |
+-----------------+
|              45 |
+-----------------+
1 row in set (0.00 sec)

mysql> select pow(9,4);
+----------+
| pow(9,4) |
+----------+
|     6561 |
+----------+
1 row in set (0.00 sec)

mysql> select round(3.14159,2);
+------------------+
| round(3.14159,2) |
+------------------+
|             3.14 |
+------------------+
1 row in set (0.00 sec)

mysql> 
mysql> select length("Hello World!");
+------------------------+
| length("Hello World!") |
+------------------------+
|                     12 |
+------------------------+
1 row in set (0.00 sec)

mysql> select length("University");
+----------------------+
| length("University") |
+----------------------+
|                   10 |
+----------------------+
1 row in set (0.00 sec)

mysql> select substring("nice to meet you",9,4);
+-----------------------------------+
| substring("nice to meet you",9,4) |
+-----------------------------------+
| meet                              |
+-----------------------------------+
1 row in set (0.00 sec)

mysql> select repeat("Cheer",3);
+-------------------+
| repeat("Cheer",3) |
+-------------------+
| CheerCheerCheer   |
+-------------------+
1 row in set (0.00 sec)

mysql> select reverse("voodoo");
+-------------------+
| reverse("voodoo") |
+-------------------+
| oodoov            |
+-------------------+
1 row in set (0.00 sec)

mysql> select concat_ws(" ","MySql","is","great");
+-------------------------------------+
| concat_ws(" ","MySql","is","great") |
+-------------------------------------+
| MySql is great                     
|
+-------------------------------------+
1 row in set (0.00 sec)

mysql> 
mysql> select week('2017-11-13',1);
+----------------------+
| week('2017-11-13',1) |
+----------------------+
|                   46 |
+----------------------+
1 row in set (0.00 sec)

mysql> select dayofweek('2017-11-14');
+-------------------------+
| dayofweek('2017-11-14') |
+-------------------------+
|                       3 |
+-------------------------+
1 row in set (0.00 sec)

mysql> select timestampdiff(year,'1929-02-14','2017-11-14');
+--------
4000
---------------------------------------+
| timestampdiff(year,'1929-02-14','2017-11-14') |
+-----------------------------------------------+
|                                           88 |
+-----------------------------------------------+
1 row in set (0.00 sec)

mysql> select date_format('2017-11-14','%y %a %D %W');
+-----------------------------------------+
| date_format('2017-11-14','%y %a %D %W') |
+-----------------------------------------+
| 17 Tue 14th Tuesday                    
|
+-----------------------------------------+
1 row in set (0.00 sec)

mysql> select second(curtime());
+-------------------+
| second(curtime()) |
+-------------------+
|                26 |
+-------------------+
1 row in set (0.00 sec)

mysql> 
mysql> show processlist;
+-----+------+-----------+------+---------+------+-------+------------------+
| Id  | User | Host     
| db   | Command | Time | State | Info             |
+-----+------+-----------+------+---------+------+-------+------------------+
| 612 | root | localhost | NULL | Sleep  
| 8843 |       | NULL             |
| 616 | root | localhost | NULL | Query  
|    0 | init  | show processlist |
+-----+------+-----------+------+---------+------+-------+------------------+
2 rows in set (0.00 sec)

mysql> select encode("mysql","ha");
+----------------------+
| encode("mysql","ha") |
+----------------------+
| 4?S?                  |
+----------------------+
1 row in set (0.00 sec)

mysql> select decode(encode("mysql","ha"),"ha");
+-----------------------------------+
| decode(encode("mysql","ha"),"ha") |
+-----------------------------------+
| mysql                             |
+-----------------------------------+
1 row in set (0.00 sec)

mysql> SELECT HEX(100);
+----------+
| HEX(100) |
+----------+
| 64       |
+----------+
1 row in set (0.00 sec)

mysql> select format("5.1584",3);
+--------------------+
| format("5.1584",3) |
+--------------------+
| 5.158              |
+--------------------+
1 row in set (0.00 sec)

mysql> select convert("new string" using "gb2312");
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  MySql