mysql中concat、RTrim、LTrim、Trim、AS

1.concat:拼接函数,可以将几个字符按照设定的格式进行拼装;

如:select concat(vend_name, ' (', vend_country, ')') from vendors ORDER BY vend_name;

+--------------------------------------------+
| concat(vend_name, ' (', vend_country, ')') |
+--------------------------------------------+
|    Anvils R Us (USA)                       |
| ACME (USA)                                 |
| Furball Inc. (USA)                         |
| Jet Set (England)                          |
| Jouets Et Ours (France)                    |
| LT Supplies (USA)                          |
+--------------------------------------------+
6 rows in set (0.00 sec)

2.RTrim:去右侧的空格;

 LTrim:去左侧的空格

 Trim:去两侧的空格;

如:select concat(Trim(vend_name), ' (', Trim(vend_country), ')') from vendors ORDER BY vend_name;

+--------------------------------------------------------+
| concat(Trim(vend_name), ' (', Trim(vend_country), ')') |
+--------------------------------------------------------+
| Anvils R Us (USA)                                      |
| ACME (USA)                                             |
| Furball Inc. (USA)                                     |
| Jet Set (England)                                      |
| Jouets Et Ours (France)                                |
| LT Supplies (USA)                                      |
+--------------------------------------------------------+
6 rows in set (0.00 sec)

 

posted @ 2021-04-22 16:33  唯一诺  阅读(504)  评论(0编辑  收藏  举报