惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - M'

AndroidStudio修改项目名称 cocos2dx2.x&3.x部分函数对照表 Ubuntu 安装mono 关于BigDecimal.ROUND_HALF_UP与ROUND_HALF_DOWN android 常用框架 理解assign,copy,retain变strong SQLSERVER2008R2正确使用索引 除非 Windows Activation Service (WAS)和万维网发布服务(W3SVC)均处于运行状态,否则无法启动网站。目前,这两项服务均处于停止状态。 Android资源命名规范 eclipse导入Android项目后,项目的名称变为了主Activity的名称 C语言位运算详解[转] Android Message里传送的数据[转] Android---组件篇---Handler的使用(1)[转] 自定义登录后台(authentication backend)[转] Nginx配置文件详细说明[转] python 进制转换[转] MySQL一些优化[转] C# Stream 和 byte[] 之间的转换[转] DotLucene(Lucene.Net)研究[转]
MySQL 去除重复的方法
M' · 2013-01-02 · via 博客园 - M'

直接看例子

例子:

     table
   id name
   1 a
   2 b
   3 c
   4 c
   5 b

1 通过 distinct 来实现

select distinct name from table

结果:

name

a

b

c

2 通过 group_concat 配合 group by 来实现 (注意:需要mysql 4.1及以上)

select  id,group_concat(distinct name) from table group by name

结果:

id name

1 a

2 b

3 c

3 通过

select id, count(distinct name) from table group by name

结果:

id name count(distinct name)

1 a 1

2 b 1

3 b 1

整理自:http://www.cnblogs.com/daiye/archive/2009/11/10/1599977.html