开发者

Is it possible to count the amount of letters in the alphabet that exists in mysql column?

开发者 https://www.devze.com 2023-02-08 07:21 出处:网络
I would like to get a count of first letters in a column. Example: My column has names likealice, jacob, james, britney and so on. I would like to count the amount of letters in the alphabet that ex

I would like to get a count of first letters in a column.

Example:

My column has names like alice, jacob, james, britney and so on. I would like to count the amount of letters in the alphabet that exists. In the above it wo开发者_开发技巧uld be 3 even though the letter "j" is repeated.

Thanks for any help.


Try

SELECT COUNT(DISTINCT SUBSTRING(`name`, 1, 1)) FROM `users`
0

精彩评论

暂无评论...
验证码 换一张
取 消