List:General Discussion« Previous MessageNext Message »
From:Thimble Smith Date:August 9 1999 5:51pm
Subject:Re: SELECT output does not keep ID order ?
View as plain text  
At 15:24, 19990808, Christos J. Pontikis wrote:
>Hello,
>I suppose that an SQL statement like "SELECT * FROM sometable"
>(without an ORDER BY id clause) will keep the auto_increment ID
>order. (MySQL 3.21.33)
>
>But, when I delete a record and after I am inserting another,
>the new record appears with the order of the deleted one (even
>if its ID is the biggest in this table).
>
>Am I doing something wrong ???

Yes.  You are expecting a some order in the results when you are
not using an ORDER BY clause.  There is NO order guaranteed, or
even suggested, in the results of a query with no ORDER BY clause.
They're not ordered by ID, by primary key, by time of insertion,
by size of node on disk, or any other arbitrary thing.  They're
just not ordered.

SQL works with sets; sets are not ordered.  If there is any order
in your data, you have to tell the RDBMS about it using the ORDER
BY clause.

Another poster said that MySQL was doing the 
Thread
SELECT output does not keep ID order ?Christos J. Pontikis8 Aug
  • Re: SELECT output does not keep ID order ?Graham Ashton8 Aug
  • Re: SELECT output does not keep ID order ?Thimble Smith9 Aug
  • Re: SELECT output does not keep ID order ?Thimble Smith9 Aug
Re: SELECT output does not keep ID order ?Christos J. Pontikis10 Aug