我写的代码:
Dim aa As Integer
txtSQL = ""
If Trim(Combo1.Text) <> "" Then
aa = 1
If txtSQL = "" Then
txtSQL = "报障部门='" & Trim(Combo1.Text) & "'"
Else
txtSQL = txtSQL & "and 报障部门='" & Trim(Combo1.Text) & "'"
End If
End If
If Trim(Combo3.Text) <> "" Then
aa = 1
If txtSQL = "" Then
txtSQL = "维修人='" & Trim(Combo3.Text) & "'"
Else
txtSQL = txtSQL & "and 维修人='" & Trim(Combo3.Text) & "'"
End If
End If
If Trim(DataCombo1.Text) <> "" Then
aa = 1
If txtSQL = "" Then
txtSQL = "维修记录='" & Trim(DataCombo1.Text) & "'"
Else
txtSQL = txtSQL & "and 维修记录='" & Trim(DataCombo1.Text) & "'"
End If
End If
If aa = 0 Then
ss = MsgBox("你至少要输入一个条件以上才能查询!", , " 警告")
Combo1.SetFocus
Exit Sub
End If
Dim str As String
str = "select * from fkd where " & txtSQL
Set mrc = ExecuteSQL(str, MsgText)
If mrc.EOF = True Then
zzz = MsgBox("对不起,没有此维修记录!", vbOKOnly, "查询")
tj.Show
tj.Combo1.SetFocus
Exit Sub
End If
txtSQL = "select * from fkd where " & txtSQL & "order by 报障编号 desc"
运行查询时,会出现重复的记录。 报障编号是唯一的
请问大家,怎样写查询语句,才能不会出现重复项。谢谢!
[讨论]如何消去查询结果中的重复项