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

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

WBOY
Release: 2016-06-23 14:23:40
Original
902 people have browsed it

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); 太感谢了

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template