Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2005
    Posts
    2

    Unanswered: retrieve only 1 row for each ID (was "Help on SQL! Urgent..")

    i have a table called tblpictures which look something like this..

    filename|ID
    ----------
    1 |p1
    2 |p1
    3 |p2
    4 |p2
    5 |p3

    is there a way to retrieve only 1 row for each ID? how will the select statement looks like?? please help me..

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Which row would you want?

    If you just want a distinct list of IDs, then this will do:

    select distinct ID from YourTable
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  3. #3
    Join Date
    Feb 2005
    Posts
    2
    erm no i want to show 1 filename and 1 ID for each ID

  4. #4
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    74
    You could probably get away with :

    select max(filename), id from tblPictures group by id

    if this is what you are looking for ...


Posting Permissions

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