mysql字段前拼接字符串_Mysql之字段字符串拼接
需求:
mysql的字符串拼接
實現:
contact(str1,str2,str3)
contact_ws(separator,str1,str2,str3)
實現中只需要注意null的問題,說明如下:
contact()中只要有一個字符串為null那么返回值為null
contact_ws():
1.separator為null時返回為null
2.其他字符串為null的時候直接跳過
例子1:
select concat(id,xf,null) from data limit 1;
值為:
寫道
+--------------------+
| concat(id,xf,null) |
+--------------------+
| NULL |
例子2:
select concat_ws(‘=‘,id,xf,null) from data limit 1;
返回值:
?
寫道
?
+------------------------------------+
| concat_ws(‘=‘,id,xf,null) |
+------------------------------------+
| 070e997f147c93113b7e522e9f355dc0=2 |
例子3:
select concat_ws(null,id,xf) from data limit 1;
返回值:
?
寫道
?
+-----------------------+
| concat_ws(null,id,xf) |
+-----------------------+
| NULL |
?
原文:http://snv.iteye.com/blog/2234929
總結
以上是生活随笔為你收集整理的mysql字段前拼接字符串_Mysql之字段字符串拼接的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【RRT三维路径规划】基于matlab
- 下一篇: 拳王虚拟项目公社:虚拟资源自动化挣钱,空