Results 1 to 3 of 3

Thread: SQL People

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618

    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!
    Sean

    Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618
    Never mind, it just came to me.....Distinct
    Sean

    Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.

  3. #3
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width