Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2001
    Posts
    1

    Unanswered: ORDER BY out of order

    I have a table like this:
    Code:
    CREATE TABLE reg_school (
      id int(10) unsigned NOT NULL auto_increment,
      country varchar(50) NOT NULL default '',
      name varchar(255) NOT NULL default '',
      activate tinyint(4) NOT NULL default '0',
      PRIMARY KEY  (id),
      UNIQUE KEY country (country,name),
      KEY activate (activate),
      FULLTEXT KEY country_2 (country)
    ) TYPE=MyISAM COMMENT='';
    and a query like this
    "SELECT * FROM reg_school WHERE country LIKE 'C%' ORDER BY country,name"

    And for some reason, the first row starts with a C and the next row is an A. Anyone knows why is that?

    MySQL Version:
    mysqladmin Ver 8.40 Distrib 4.0.13, for pc-linux on i686
    Linux 2.4.20-13.7

    Thanks for any help

  2. #2
    Join Date
    Jan 2003
    Location
    Paris, France
    Posts
    320
    wich field begin with C or A
    Olivier Miossec
    --
    http://www.lasso-developpeur.net/
    --

  3. #3
    Join Date
    Sep 2002
    Location
    Montreal, Canada
    Posts
    224
    Provided Answers: 1

    Re: ORDER BY out of order

    Originally posted by Son Nguyen
    I have a table like this:
    Code:
    CREATE TABLE reg_school (
      id int(10) unsigned NOT NULL auto_increment,
      country varchar(50) NOT NULL default '',
      name varchar(255) NOT NULL default '',
      activate tinyint(4) NOT NULL default '0',
      PRIMARY KEY  (id),
      UNIQUE KEY country (country,name),
      KEY activate (activate),
      FULLTEXT KEY country_2 (country)
    ) TYPE=MyISAM COMMENT='';
    and a query like this
    "SELECT * FROM reg_school WHERE country LIKE 'C%' ORDER BY country,name"

    And for some reason, the first row starts with a C and the next row is an A. Anyone knows why is that?

    MySQL Version:
    mysqladmin Ver 8.40 Distrib 4.0.13, for pc-linux on i686
    Linux 2.4.20-13.7

    Thanks for any help
    Are you sure it's not a case like like ' Colorado' and then 'Arizona' (see the blank in front of Colorado)?

  4. #4
    Join Date
    Jun 2003
    Location
    México
    Posts
    5

    Re: ORDER BY out of order

    Originally posted by Son Nguyen
    I have a table like this:
    Code:
    CREATE TABLE reg_school (
      id int(10) unsigned NOT NULL auto_increment,
      country varchar(50) NOT NULL default '',
      name varchar(255) NOT NULL default '',
      activate tinyint(4) NOT NULL default '0',
      PRIMARY KEY  (id),
      UNIQUE KEY country (country,name),
      KEY activate (activate),
      FULLTEXT KEY country_2 (country)
    ) TYPE=MyISAM COMMENT='';
    and a query like this
    "SELECT * FROM reg_school WHERE country LIKE 'C%' ORDER BY country,name"

    And for some reason, the first row starts with a C and the next row is an A. Anyone knows why is that?

    MySQL Version:
    mysqladmin Ver 8.40 Distrib 4.0.13, for pc-linux on i686
    Linux 2.4.20-13.7

    Thanks for any help
    Hi, It could not be the presence of a blank space before ' C' due to the SELECT statement force the field to start with a 'C' as well if you see a country which name begins with a different caracter than a 'C' in the result of your query then you should try to recreate the table.

Posting Permissions

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