SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru DeNasio's Avatar
    Join Date
    May 2001
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need some help sorting in MySQL

    Hello,

    I'm using the MySQL code you see on this page to insert the country codes and names in my database. I've added the following extra line:

    INSERT INTO `countries` VALUES ('--', '(not listed)');

    I'm using the following code to fetch the countries:

    $result = @mysql_query("SELECT * FROM countries ORDER BY country ASC");

    But the output always gives me (not listed) first and then the countries. I would like to see all the countries first, then the last output (not listed). Any one knows how I can do this in one MySQL statement?
    Ballot-Box.net - free polls for webmasters
    FormLog.com - free form processor

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,273
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    ORDER BY CASE WHEN ccode = '--' THEN 'humpty' ELSE 'dumpty' END, ccode

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


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
  •