A Taste of MySql 函数(1)


mysql> select char_length('김일택');
+--------------------------+
| char_length('김일택') |
+--------------------------+
|                        9 |
+--------------------------+
1 row in set (0.00 sec)

mysql> select length('김일택');
+---------------------+
| length('김일택') |
+---------------------+
|                   9 |
+---------------------+
1 row in set (0.00 sec)

mysql> select char_length('今日则');
+--------------------------+
| char_length('今日则') |
+--------------------------+
|                        9 |
+--------------------------+
1 row in set (0.00 sec)

mysql> select char_length("jinrize");
+------------------------+
| char_length("jinrize") |
+------------------------+
|                      7 |
+------------------------+
1 row in set (0.00 sec)

mysql> select concat('jin','ri','ze');
+-------------------------+
| concat('jin','ri','ze') |
+-------------------------+
| jinrize                 |
+-------------------------+
1 row in set (0.00 sec)

mysql> select locate('jin','jinrize');
+-------------------------+
| locate('jin','jinrize') |
+-------------------------+
|                       1 |
+-------------------------+
1 row in set (0.00 sec)

mysql> select instr('jin','jinrize');
+------------------------+
| instr('jin','jinrize') |
+------------------------+
|                      0 |
+------------------------+
1 row in set (0.00 sec)

mysql> select instr('jin','j');
+------------------+
| instr('jin','j') |
+------------------+
|                1 |
+------------------+
1 row in set (0.00 sec)

mysql> select lpad('jin',7,'*');
+-------------------+
| lpad('jin',7,'*') |
+-------------------+
| ****jin           |
+-------------------+
1 row in set (0.00 sec)

mysql> select rpad('jin',7,'*');
+-------------------+
| rpad('jin',7,'*') |
+-------------------+
| jin****           |
+-------------------+
1 row in set (0.00 sec)

mysql> select left('jin',2);
+---------------+
| left('jin',2) |
+---------------+
| ji            |
+---------------+
1 row in set (0.00 sec)

mysql> select right('jinrize',2);
+--------------------+
| right('jinrize',2) |
+--------------------+
| ze                 |
+--------------------+
1 row in set (0.00 sec)

mysql> select substring('jinrize',3,4);
+--------------------------+
| substring('jinrize',3,4) |
+--------------------------+
| nriz                     |
+--------------------------+

1 row in set (0.00 sec)

 
mysql> select ltrim('   jinrize');
+---------------------+
| ltrim('   jinrize') |
+---------------------+
| jinrize             |
+---------------------+
1 row in set (0.00 sec)

mysql> select ltrim('   jinrize    ');
+-------------------------+
| ltrim('   jinrize    ') |
+-------------------------+
| jinrize                 |
+-------------------------+
1 row in set (0.00 sec)

mysql> select rtrim('   jinrize    ');
+-------------------------+
| rtrim('   jinrize    ') |
+-------------------------+
|    jinrize              |
+-------------------------+
1 row in set (0.00 sec)

mysql> select trim('   jinrize    ');
+------------------------+
| trim('   jinrize    ') |
+------------------------+
| jinrize                |
+------------------------+
1 row in set (0.00 sec)

mysql> select trim(leading 'x' from 'xxxjinrizexxx');
+----------------------------------------+
| trim(leading 'x' from 'xxxjinrizexxx') |
+----------------------------------------+
| jinrizexxx                             |
+----------------------------------------+
1 row in set (0.00 sec)

mysql> select trim(both 'x' from 'xxxjinrizexxx');
+-------------------------------------+
| trim(both 'x' from 'xxxjinrizexxx') |
+-------------------------------------+
| jinrize                             |
+-------------------------------------+
1 row in set (0.00 sec)

mysql> select trim(trailing 'x' from 'xxxjinrizexxx');
+-----------------------------------------+
| trim(trailing 'x' from 'xxxjinrizexxx') |
+-----------------------------------------+
| xxxjinrize                              |
+-----------------------------------------+
1 row in set (0.00 sec)

你可能感兴趣的:(mysql)