SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Free your mind Toly's Avatar
    Join Date
    Sep 2001
    Location
    Panama
    Posts
    2,181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Displaying info in alphabetical order

    Hello,

    I have a database with more than 30 names and i would like to display the names on a web page in alphabetical order.

    How can i do this?

    Thanks.

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,251
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    just a wee bit more info, please

    what database? what does the database table look like?

    you'll want something like

    select lastname, firstname
    from yourtable
    order by lastname, firstname
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    Free your mind Toly's Avatar
    Join Date
    Sep 2001
    Location
    Panama
    Posts
    2,181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's a mysql db.

    It's just a simple table with a column "names". I want to display all the names inside that column in alphabetical order..... the names starting with the letter "A" will go first, then the ones with the letter "B" and so on.

  4. #4
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    SELECT names FROM table ORDER BY names

    If you actually want to display them like this it will be harder though:

    A
    Adam
    Andrew

    B
    Ben
    Bob

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  5. #5
    Free your mind Toly's Avatar
    Join Date
    Sep 2001
    Location
    Panama
    Posts
    2,181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Geesh! Sorry, i guess that was a really stupid question. It's just that i have always order my data using the ID column which orders the values from 1-10 (if i only had 10 rows for instance) so i thought it would do the same thing with the names, ordering them from the first one inserted to the lastone.


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
  •