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

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

WBOY
Release: 2016-06-13 10:09:19
Original
913 people have browsed it

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

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;

Related labels:
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