Solved

What's the sort order on a MySql database if you don't specify one?

Posted on 2010-09-21
8
290 Views
Last Modified: 2013-12-12
What does a MySQL database sort by when you don't specify anything. In other words, if you just ask for an array with no sorting criteria at all, in what order does it provide the data?
0
Comment
Question by:brucegust
8 Comments
 

Author Comment

by:brucegust
Comment Utility
Head out to http://www.elivestockauctions.com/auctions/preview. There's an array being created using a JQuery approach and since there's no sort functionality offered natively, I'm trying to figure out how the data is being presented so I can hot wire some things and provide the user with a logical sequence.
0
 
LVL 32

Accepted Solution

by:
ewangoya earned 125 total points
Comment Utility
Its in the order in which it is inserted in the table if there is no index defined
0
 

Author Comment

by:brucegust
Comment Utility
The id is the Primary field with four other fields listed as indexes.

When I sort by the "created_date," that's not the order in which the data is displayed. But when I hit "Browse" in my phpMyAdmin, the order in which that data is displayed is exactly the way it shows up on the page.

What can I do to figure out the way in which the system is sorting this?
0
 
LVL 3

Assisted Solution

by:celdridgeMadman
celdridgeMadman earned 250 total points
Comment Utility
Depends on the table type as well. InnoDB will store records in the order of the Primary Key, whilst MyISAM will store them in the order entered.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 4

Assisted Solution

by:rstjean
rstjean earned 125 total points
Comment Utility
Try using the explain command.

EXPLAIN SELECT * FROM animals.  can run this from phpmyadmin.

If you have a problem with indexes not being used when you believe that they should be, you should run ANALYZE TABLE
0
 

Author Comment

by:brucegust
Comment Utility
Here's what I get when I run "EXPLAIN..."

id  select_type  table  type  possible_keys  key  key_len  ref  rows  Extra  
1 SIMPLE lots ALL NULL NULL NULL NULL 66  
 
What does that mean as far as how data is being sorted?

As far as the table type, how would I figure that out?

0
 
LVL 3

Assisted Solution

by:celdridgeMadman
celdridgeMadman earned 250 total points
Comment Utility
the query SHOW TABLE STATUS FROM tblname shoudl return that information for you. Provided you have the necessary permissions. If not you'll need to get the DBA for that server to obtain it for you.
0
 

Author Closing Comment

by:brucegust
Comment Utility
This answered my question.
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now