-
SQL People
I'm writing this ADO.NET/VB.NET application, and I am trying to select a group of records from a database. I want one record each for each user ID in the table. That is to say, if a user ID appears in three different records, I just want the first one. I'm pretty sure there is a SQL Keyword for that but I am drawing a blank. Anybody have any thoughts? Thanks!
-
Never mind, it just came to me.....Distinct
-
Distinct does not give you "the 1st one"
It returns a row that is unique. ie: (3 fields in user table)
SELECT * FROM Users
returns
Woka, "admin", 3
Woka, "admin", 3
Then
SELECT DISTINCT * FROM Users
returns
Woka, "admin", 3
make sense?
If:
SELECT * FROM Users
returns
Woka, "admin", 4
Woka, "admin", 3
Then
SELECT DISTINCT * FROM Users
returns
Woka, "admin", 4
Woka, "admin", 3
But
SELECT DISTINCT Username FROM Users
would return
Woka
Have I just rambled rubbish there?
Woof