dim rsColor as new ado.recordsetrsColor.open "select distinct Color from 表",conn,.....
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
要从两个字段中提取所有不同的值,怎么办?例如姓名 爱好1 爱好2 g 篮球 足球 e 足球 羽毛球 h 乒乓球 j 乒乓球 羽毛球 e 排球 y 羽毛球 篮球该表中共有哪几种爱好,提取到一个集合中,结果应当是:篮球、足球、羽毛球、排球、乒乓球求代码,多谢!
select distinct 爱好1 from table union select distinct 爱好2 from table where 爱好2 not in(select 爱好1 from table)效率不高,比较死板,单论这个表的话可以这么做!数据量大的话,做个自定义函数,比较处理!
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
g 篮球 足球
e 足球 羽毛球
h 乒乓球
j 乒乓球 羽毛球
e 排球
y 羽毛球 篮球该表中共有哪几种爱好,提取到一个集合中,结果应当是:篮球、足球、羽毛球、排球、乒乓球求代码,多谢!
union
select distinct 爱好2 from table where 爱好2 not in(select 爱好1 from table)效率不高,比较死板,单论这个表的话可以这么做!数据量大的话,做个自定义函数,比较处理!