char_length():单位为字符,不管汉字还是数字或者是字母都算是一个字符。
length() : 单位是字节,utf8编码下,一个汉字三个字节,一个数字或字母一个字节。
gbk编码下,一个汉字两个字节,一个数字或字母一个字节。
描述
牛客有评论记录表`comment_detail`,输出字数大于3的评论的id,comment,且去除其中的中文逗号,查询返回结果名称和顺序为
id|comment
`comment_detail`
解答
select id
,replace(comment, ',', '') comment
from comment_detail
where char_length(comment) > 3;