SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: selecting

  1. #1
    SitePoint Guru
    Join Date
    Apr 2001
    Location
    BC, Canada
    Posts
    630
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    selecting

    I have a database filled with articles...
    there are two types

    current
    past

    they are indicate in a collum named 'type'

    Using a select statement in mysql, how could I retrive all the articles in alphabetical order, but have current first...

    so it would be current a-z then past a-z
    I want to be able to do this in one satement



    thanx

  2. #2
    SitePoint Enthusiast tipiyanos's Avatar
    Join Date
    Jun 2001
    Location
    NY, New York
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    SELECT article_text FROM article_table ORDER BY typearticle_text 
    This should work no? It will first order the query result by type(current/past) and the alphabetical order of article_text.

    Hope that helps.

  3. #3
    You want what? By when?? Milamber's Avatar
    Join Date
    Jan 2001
    Location
    California
    Posts
    342
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:

    "SELECT title FROM articles_table ORDER BY age, title ASC" 

    That statement will sort the table alphabetically by age (your current/pass column ) first, and then by the title column.

    Thus giving you a list with the titles that are in alphabetical order and start over at current/past differences.


    I believe this will work, but not sure, so please let me know if it does.



    Good luck!
    -Jeff Minard | jrm.cc - Battlefield 2 Stats

  4. #4
    SitePoint Guru
    Join Date
    Apr 2001
    Location
    BC, Canada
    Posts
    630
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nope..that dosnt seem to work

  5. #5
    You want what? By when?? Milamber's Avatar
    Join Date
    Jan 2001
    Location
    California
    Posts
    342
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by slighltywhacked
    nope..that dosnt seem to work
    bummer - other than that i suggest you go read the mysql documentation.
    -Jeff Minard | jrm.cc - Battlefield 2 Stats


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
  •