[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2010-09-21
8
Medium Priority
?
299 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 

Author Comment

by:brucegust
ID: 33730810
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:
Ephraim Wangoya earned 500 total points
ID: 33730854
Its in the order in which it is inserted in the table if there is no index defined
0
 

Author Comment

by:brucegust
ID: 33730972
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
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
LVL 3

Assisted Solution

by:celdridgeMadman
celdridgeMadman earned 1000 total points
ID: 33731010
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
 
LVL 4

Assisted Solution

by:rstjean
rstjean earned 500 total points
ID: 33731034
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
ID: 33731067
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 1000 total points
ID: 33731109
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
ID: 33775047
This answered my question.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

656 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