1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Help Requested :)

Discussion in 'Databases' started by Darkhodge, Dec 25, 2006.

  1. #1
    Hey,


    I have a database that has information about bands. Basically it has the artist name and song name etc...

    If I have a database with the following content:

    artistName............songName
    Muse................Plug in Baby
    Muse................Starlight
    Muse................Newborn
    Muse................Bliss
    Strokes.............Is This It
    Strokes.............Heart in a Cage
    Strokes.............Last Night

    What SQL do I need to use to I select the artistNames so that each unique value only shows up once?

    So for the example above I want to get "Muse" and "Strokes", instead of "Muse", "Muse", "Muse", "Muse", "Strokes", "Strokes", "Strokes", which is given by the SQL "SELECT artistName FROM artistInfo"?


    Thanks,

    Hodge :)
     
    Darkhodge, Dec 25, 2006 IP
  2. rknuppel

    rknuppel Well-Known Member

    Messages:
    753
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    153
    #2
    SELECT DISTINCT artistName FROM artistInfo
     
    rknuppel, Dec 25, 2006 IP
  3. nocookies

    nocookies Peon

    Messages:
    57
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    SELECT DISTINCT artistName FROM artistInfo

    or

    SELECT artistName FROM artistInfo GROUP BY artistName;

    You can get the number of songs each artist has for free in this way:

    SELECT artistName,COUNT(*) FROM artistInfo GROUP BY artistName;
     
    nocookies, Dec 25, 2006 IP
  4. Darkhodge

    Darkhodge Well-Known Member

    Messages:
    2,111
    Likes Received:
    76
    Best Answers:
    1
    Trophy Points:
    185
    #4
    Cheers guys that worked a treat :)
     
    Darkhodge, Dec 26, 2006 IP