Home >Backend Development >PHP Tutorial > 像这种表,应该如何统计比较有效率

像这种表,应该如何统计比较有效率

WBOY
WBOYOriginal
2016-06-13 13:48:50970browse

像这种表,应该怎么统计比较有效率?
表里的内容如下:

id bid
1 138
2 150
3 139
4 139
5 139
6 138
7 138
8 150


我只要统计bid字段里的值,不要重复的

应该怎么统计比较有效率?

统计结果如下:
138
150
139

------解决方案--------------------
group by bid;
------解决方案--------------------
select distinct bid from table_name;
------解决方案--------------------
select distinct bid from table_name;
------解决方案--------------------
SELECT DISTINCT bid FROM t;

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