SitePoint Sponsor

User Tag List

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

    Tricky select - if even possible

    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 SAMDB. 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 by their first letter. Anyone got a suggestion? Here's some graphich candy for you just to examplify things:





    Thanks,
    Sensei

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,347
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    select artist, title, album
    from samdb
    where album like 'A%'
    order by album
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Enthusiast
    Join Date
    Jun 2003
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your quick answer, but as I feared when I echo out the album name after that SELECT it prints the name the same number of times that it is saved in the db. Sorry if I didn't specify that I only wanted it to be printed once. How do I limit it?

    Thanks,
    Sensei

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,347
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    if you mean you want this data --

    Code:
    bob marley   a touch of reggae  lively up yourself
    bob marley   soul rebel         fussin' fightin'
    bob marley   natural mystic     soon come
    to be listed like this --
    Code:
    bob marley
       a touch of reggae  lively up yourself
       soul rebel         fussin' fightin'
       natural mystic     soon come
    then the answer is, you have to do that in your calling script


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
  •