Home  >  Article  >  Backend Development  >  求教写一句sql,sql大牛请进!!

求教写一句sql,sql大牛请进!!

WBOY
WBOYOriginal
2016-06-23 14:23:40855browse

sql mysql php


以某字段的第一个字符分组,列出不同的结果


如:
        id             name
        1              张三
        2              李四
        3              黄五
        4              张一
        5              李六
        6              陈七

查询结果:张,李,黄,陈。

回复讨论(解决方案)

select left(name,1) from tt group by left(name,1);

select left(name,1) from tt group by left(name,1); 太感谢了

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