yiki

直接看例子

例子:

     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

 

分类:

技术点:

相关文章:

  • 2021-12-28
  • 2021-12-28
  • 2021-12-28
  • 2022-01-20
  • 2021-11-28
  • 2021-12-18
  • 2021-12-18
  • 2021-12-18
猜你喜欢
  • 2021-08-02
  • 2021-08-02
  • 2021-12-09
  • 2019-11-27
  • 2021-12-09
  • 2021-11-23
  • 2021-12-28
相关资源
相似解决方案