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

mysql部分函数试用

2016-08-17 15:36 302 查看
mysql> select ASCII("2");

+------------+

| ASCII("2") |

+------------+

|         50 |

+------------+

1 row in set

mysql> select BIN(12);

+---------+

| BIN(12) |

+---------+

| 1100    |

+---------+

1 row in set

mysql> select BIN(1

12);

+----------+

| BIN(112) |

+----------+

| 1110000  |

+----------+

1 row in set

mysql> select ASCII("a

");

+------------+

| ASCII("a") |

+------------+

|         97 |

+------------+

1 row in set

mysql> select CONV("a",10,2);

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select CONV("a",10,2)' at line 3

mysql> select CONV("a",16

,2);

+----------------+

| CONV("a",16,2) |

+----------------+

| 1010           |

+----------------+

1 row in set

mysql> select conv(16,10,16);

+----------------+

| conv(16,10,16) |

+----------------+

| 10             |

+----------------+

1 row in set

mysql> select conv(16,10,15

);

+----------------+

| conv(16,10,15) |

+----------------+

| 11             |

+----------------+

1 row in set

mysql> select char(97);

+----------+

| char(97) |

+----------+

| a        |

+----------+

1 row in set

mysql> select concat('my','sql');

+--------------------+

| concat('my','sql') |

+--------------------+

| mysql              |

+--------------------+

1 row in set

mysql> select left('school',3);

+------------------+

| left('school',3) |

+------------------+

| sch              |

+------------------+

1 row in set

mysql> select substring('school',3,4

);

+-------------------------+

| substring('school',3,4) |

+-------------------------+

| hool                    |

+-------------------------+

1 row in set

mysql> select substring('school',3,10

);

+--------------------------+

| substring('school',3,10) |

+--------------------------+

| hool                     |

+--------------------------+

1 row in set

mysql> select substring('school',3,2

);

+-------------------------+

| substring('school',3,2) |

+-------------------------+

| ho                      |

+-------------------------+

1 row in set

mysql> select trim('scsssv   ho ol'

);

+------------------------+

| trim('scsssv   ho ol') |

+------------------------+

| scsssv   ho ol         |

+------------------------+

1 row in set

mysql> select l

trim('   scsssv   ho ol');

+----------------------------+

| ltrim('   scsssv   ho ol') |

+----------------------------+

| scsssv   ho ol             |

+----------------------------+

1 row in set

mysql> select r

trim('   scsssv   ho ol         ');

+-------------------------------------+

| rtrim('   scsssv   ho ol         ') |

+-------------------------------------+

|    scsssv   ho ol                   |

+-------------------------------------+

1 row in set

mysql> select 

trim('   scsssv   ho ol         ');

+------------------------------------+

| trim('   scsssv   ho ol         ') |

+------------------------------------+

| scsssv   ho ol                     |

+------------------------------------+

1 row in set

mysql> select soundex("schul");

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select soundex("schul")' at line 3

mysql> select soundex("schoo

l");

+-------------------+

| soundex("school") |

+-------------------+

| S400              |

+-------------------+

1 row in set

mysql> select soundex("hello

");

+------------------+

| soundex("hello") |

+------------------+

| H400             |

+------------------+

1 row in set

mysql> select space('   ');

+--------------+

| space('   ') |

+--------------+

|              |

+--------------+

1 row in set

mysql> select reverse('sadfaf asfdawwww');

+-----------------------------+

| reverse('sadfaf asfdawwww') |

+-----------------------------+

| wwwwadfsa fafdas            |

+-----------------------------+

1 row in set

mysql> select replace('ouousfsf','sf','ssff');

+---------------------------------+

| replace('ouousfsf','sf','ssff') |

+---------------------------------+

| ououssffssff                    |

+---------------------------------+

1 row in set

mysql> select export_set(23,'23','Y','YWE','ss');

+------------------------------------+

| export_set(23,'23','Y','YWE','ss') |

+------------------------------------+

|                                    |

+------------------------------------+

1 row in set

mysql> select export_set(23,'23','Y','YWE','ss');

+------------------------------------+

| export_set(23,'23','Y','YWE','ss') |

+------------------------------------+

|                                    |

+------------------------------------+

1 row in set

mysql> select ucase

(23,'23','Y','YWE','ss');

1582 - Incorrect parameter count in the call to native function 'ucase'

1582 - Incorrect parameter count in the call to native function 'ucase'

    -> 

    -> select ucase('Hey');

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1582 - Incorrect parameter count in the call to native function 'ucase'

sele' at line 1

mysql> ;

1065 - Query was empty

mysql> select UCASE

('Hey');

+--------------+

| UCASE('Hey') |

+--------------+

| HEY          |

+--------------+

1 row in set

mysql> select (select UCASE('ucase

'))('Hey');

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '('Hey')' at line 1

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '('Hey')' at line 1

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1064 - You have an error in your SQL syntax' at line 1

    -> 

    -> select hour('8:00:00');

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'the manual that corresponds to your MySQL server version for the right syntax to' at line 1

mysql> select HOUR

('8:00:00');

+-----------------+

| HOUR('8:00:00') |

+-----------------+

|               8 |

+-----------------+

1 row in set

mysql> select HOUR('

11:00:00');

+------------------+

| HOUR('11:00:00') |

+------------------+

|               11 |

+------------------+

1 row in set

mysql> select curdate();

+------------+

| curdate()  |

+------------+

| 2016-08-17 |

+------------+

1 row in set

mysql> select curtime

();

+-----------+

| curtime() |

+-----------+

| 15:15:02  |

+-----------+

1 row in set

mysql> select concat(select curtime(),select curdate());

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select curtime(),select curdate())' at line 1

mysql> 

mysql> 

mysql> select maketime(2016,220);

1582 - Incorrect parameter count in the call to native function 'maketime'

mysql> select MAKETIME

(2016,220);

1582 - Incorrect parameter count in the call to native function 'MAKETIME'

1582 - Incorrect parameter count in the call to native function 'MAKETIME'

    -> select time(8:22:22);

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1582 - Incorrect parameter count in the call to native function 'MAKETIME'

s' at line 1

mysql> 

mysql> 

mysql> 

mysql> select Now();

+---------------------+

| Now()               |

+---------------------+

| 2016-08-17 15:18:07 |

+---------------------+

1 row in set

mysql> select TIMESTAMP();

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1

mysql> select TIMESTAMP(23

);

+---------------+

| TIMESTAMP(23) |

+---------------+

| NULL          |

+---------------+

1 row in set

mysql> select SLEEP

(3);

+----------+

| SLEEP(3) |

+----------+

|        0 |

+----------+

1 row in set

mysql> select UUID

();

+--------------------------------------+

| UUID()                               |

+--------------------------------------+

| 10d3ad27-644b-11e6-bee7-507b9d17ef78 |

+--------------------------------------+

1 row in set

mysql> select UUID();

+--------------------------------------+

| UUID()                               |

+--------------------------------------+

| 134b4482-644b-11e6-bee7-507b9d17ef78 |

+--------------------------------------+

1 row in set
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息