8.计算字段
concat () 拼接串
mysql> select concat (name,‘-‘,msg) from pw_luck; +-----------------------+ | concat (name,‘-‘,msg) | +-----------------------+ | Wilson-100 | | zhangsan-100 | | lisi-1001 | | wang5-1001 | | zhangsan7-1000 | | zhangsan8-1000 | | zhangsan9-1000 | | wang5-1000 | | wang5%-2000 | | WANG5-1000 | +-----------------------+ 10 rows in set (0.00 sec)
RTrim() 去掉右侧空格 LTrim() 去掉左侧空格 Trim() 去掉空格
as 别名:
mysql> select concat (name,‘-‘,msg) as temp from pw_luck order by temp;
+----------------+
| temp |
+----------------+
| lisi-1001 |
| wang5%-2000 |
| WANG5-1000 |
| wang5-1000 |
| wang5-1001 |
| Wilson-100 |
| zhangsan-100 |
| zhangsan7-1000 |
| zhangsan8-1000 |
| zhangsan9-1000 |
+----------------+
10 rows in set (0.00 sec)
时间: 2024-10-13 07:27:51