SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2006
    0 Post(s)
    0 Thread(s)

    Table primary key column out of order


    I have a table which has an auto incrementing primary key column which for some reason is out of order.

    I can sort it in phpmyadmin but it keeps falling out of order and I'm not sure why.

    Any thoughts anyone ?

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    West Springfield, Massachusetts
    198 Post(s)
    3 Thread(s)
    Are they being assigned numbers out of order? Or do they only look out of order to you when using phpMyAdmin?

    Try this comparison. You normally read left to right, top to bottom. Do you fill your kitchen cabinets and drawers that way? Or do you put things where they'll fit and where you can get the most frequently used items more easily?

    MySQL does something similar. It only looks out of order to you, to MySQL it makes perfect sense.

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Sydney, NSW, Australia
    25 Post(s)
    1 Thread(s)
    Quote Originally Posted by jominsons View Post
    I can sort it in phpmyadmin but it keeps falling out of order and I'm not sure why.
    To tell phpmyadmin to order by any particular field you need to click once on the field heading for ascending order and twice for decending order.

    Databases do not keep the data in order by any particular field - they keep the data arranged to minimise the space it uses and maximise the ability to retrieve whatever is required quickly. Any order is imposed by specifying the order you want the desired information tretrieved in.
    Stephen J Chapman, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


Posting Permissions

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