Home > Database > Mysql Tutorial > mysql去重计数_MySQL

mysql去重计数_MySQL

WBOY
Release: 2016-06-01 13:17:53
Original
2317 people have browsed it

bitsCN.com

要求:

有两个表ttest1、ttest2,结构如下,求 localname ,用户数

ttest1:地区码、用户id

/

/ttest2 :地区名、地区码/
/sql:
SELECT localname , COUNT( DISTINCT uid )FROM ttest1,ttest2WHERE ttest1.localid = ttest2.localidGROUP BY localname
结果:/
缺陷:对于地区d,没有显示用户为0
大家有什么好的方法,欢迎回复 bitsCN.com
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