例如
字段1   字段2    字段3
1       a        x
2       b        y
3       a        x
4       c        z
5       b        z
6       d        x把字段2中所有不同的值a、b、c、d提取到一个集合中多谢

解决方案 »

  1.   

    select distinct field2 from 表
      

  2.   

    dim rsColor as new ado.recordsetrsColor.open "select distinct Color from 表",conn,.....
      

  3.   

    Dim r As New ADODB.Recordset
    Dim SQL As String
    SQL = " SELECT DISTINCT lb  AS T1 FROM s_tab_zgxx WHERE ZT='" & ZT & "'"
    r.Open SQL, cn
    Do While Not r.EOF
        Combo1.AddItem (Trim(r!T1 & " "))
    r.MoveNext
    Loop
    r.Close
      

  4.   

    要从两个字段中提取所有不同的值,怎么办?例如姓名  爱好1    爱好2
    g    篮球      足球
    e    足球      羽毛球
    h    乒乓球    
    j    乒乓球    羽毛球
    e    排球
    y    羽毛球    篮球该表中共有哪几种爱好,提取到一个集合中,结果应当是:篮球、足球、羽毛球、排球、乒乓球求代码,多谢!
      

  5.   

    select distinct 爱好1 from table
    union
    select distinct 爱好2 from table where 爱好2 not in(select 爱好1 from table)效率不高,比较死板,单论这个表的话可以这么做!数据量大的话,做个自定义函数,比较处理!