SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2003
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question How to print this string only once?

    I'm working on a request system to work with a database used by Streaming Audio Manager (SAM2) where data such as album name, track title, artist etc. is stored. Now, the problem is that the guy who made it didn't make much of a relational database so it's all in one huge table called songinfo where every song is stored with lots of data. I want to make a list of all the letters so that when a user clicks on e.g. "A" all albums starting with A is listed. If this db had been a bit different I could have done it easily, but the way it is now I have no idea how I can list all albums starting with e.g. "A" without printing each album the same number of times it is stored in the db. Here's a graphic illustrating a part of the table:



    I also posted about this in the SQL-forums and so far I've been using this SELECT:
    Code:
    SELECT * from songlist WHERE album like 'A%' order by album
    But echoing the album name will print it the number of times it is saved in the table. (E.g. From the image you can see that there are five tracks from "A Few Good Men" so it will print "A Few Good MenA Few Good MenA Few Good MenA Few Good MenA Few Good Men" and the same for the rest of the albums.) How can I make it print each album only once? Like this: "A Few Good Men A Fistful Of Dollars A Knight's Tale"

    Thanks,
    Sensei

  2. #2
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Code:
    SELECT DISTINCT album, artist, track_title
    FROM songlist
    WHERE album LIKE 'A%'
    ORDER BY album

  3. #3
    SitePoint Enthusiast
    Join Date
    Jun 2003
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That wasn't too hard. Thanks! ;-)

  4. #4
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Always glad to help

  5. #5
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ouch - You've beaten me to it


Bookmarks

Posting Permissions

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