Home  >  Article  >  Database  >  MySQL 查询结果以百分比显示简单实现_MySQL

MySQL 查询结果以百分比显示简单实现_MySQL

WBOY
WBOYOriginal
2016-06-01 13:25:201197browse

bitsCN.com 找了一些资料,然后我是用到了MySQL字符串处理中的两个函数concat()和left()

1、CONCAT(str1,str2,...)
返回来自于参数连结的字符串。如果任何参数是NULL, 返回NULL。可以有超过2个的参数。一个数字参数被变换为等价的字符串形式。

示例

select CONCAT('My', 'S', 'QL');
-> 'MySQL'

select CONCAT('My', NULL, 'QL');
-> NULL

select CONCAT(14.3);
-> '14.3'

2、LEFT(str,length)
从左开始截取字符串.说明:left(被截取字段,截取长度)

结合1、2 :concat ( left (数值1 / 数值2 *100,5),'%') as 投诉率bitsCN.com

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn