• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 300
  • Last Modified:

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

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
brucegust
Asked:
brucegust
4 Solutions
 
brucegustAuthor Commented:
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
 
Ephraim WangoyaCommented:
Its in the order in which it is inserted in the table if there is no index defined
0
 
brucegustAuthor Commented:
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
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
celdridgeMadmanCommented:
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
 
rstjeanCommented:
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
 
brucegustAuthor Commented:
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
 
celdridgeMadmanCommented:
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
 
brucegustAuthor Commented:
This answered my question.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now