Click to See Complete Forum and Search --> : Access and DISTINCT


Nicodemas
04-30-2003, 06:53 AM
Does Access support DISTINCT SQL calls?

I am having a tissy about this one statement in my code, in that it is not pulling only the distinct, individual last name, first name combinations.


<%
strSQL = "SELECT DISTINCT ID, Rank, LName, FName FROM tblPOC"
ysnSuccess = adlExecuteSQL (strDB, strSQL, RSPeople)
Do Until RSPeople.EOF
Response.Write("<option value=" & RSPeople("ID") & ">" & RSPeople("Rank") & " " & RSPeople("LName") & ", " & RSPeople("FName"))
RSPeople.movenext
Loop

RSPeople.Close
Set RSPeople = Nothing
%>


Is it my ID field that is screwing it up? The ID field is a primary key, and therefore distinct... but I've never used distinct until now so I have no idea how that works.

Nicodemas
04-30-2003, 08:00 AM
Hmmm...

Tried
ORDER BY LName
and...
ORDER BY LName GROUP BY LName

With no satisfactory results.

strSQL = "SELECT DISTINCT ID, Rank, LName, FName FROM tblPOC ORDER BY LName GROUP BY LName"

Nicodemas
05-01-2003, 01:00 AM
I have no idea what that says :D

Anywho, I tried to plug it in (copy and paste) and I changed the name Table1 to the name of my table ... but... uh.. well, you lost me.