MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 13th, 2012, 03:24 AM
claudia23 claudia23 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 3 claudia23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 41 sec
Reputation Power: 0
Order entry problem

Hi everybody,
I have a MyIsam DB and one of my tables gives me the following problem:
The order of the entry is visualize by default by descenting order whilst is should not.
To details:
This is the description of the table:
+-------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+----------------+
| id_voice | int(11) | NO | PRI | NULL | auto_increment |
| id_project | int(11) | YES | | 0 | |
| description | varchar(255) | NO | | NULL | |
+-------------+--------------+------+-----+---------+----------------+

This is as it is
+----------+------------+-------------+
| id_voice | id_project | description |
+----------+------------+-------------+
| 4 | 1 | OTHER |
| 3 | 1 | MNG |
| 2 | 1 | DEMO |
| 1 | 1 | RTD |
+----------+------------+-------------+

As it should be
+----------+------------+-------------+
| id_voice | id_project | description |
+----------+------------+-------------+
| 1 | 1 | RTD |
| 2 | 1 | DEMO |
| 3 | 1 | MNG |
| 4 | 1 | OTHER |
+----------+------------+-------------+

May anybody explain be this?
There no motivation thus it should happen in my opinion.

Thanks
Claudia

Reply With Quote
  #2  
Old October 13th, 2012, 04:15 AM
TASB TASB is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2009
Posts: 155 TASB User rank is Second Lieutenant (5000 - 10000 Reputation Level)TASB User rank is Second Lieutenant (5000 - 10000 Reputation Level)TASB User rank is Second Lieutenant (5000 - 10000 Reputation Level)TASB User rank is Second Lieutenant (5000 - 10000 Reputation Level)TASB User rank is Second Lieutenant (5000 - 10000 Reputation Level)TASB User rank is Second Lieutenant (5000 - 10000 Reputation Level)TASB User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 4 Days 8 h 9 m 7 sec
Reputation Power: 88
What is the syntax of the query you are running?

Reply With Quote
  #3  
Old October 13th, 2012, 04:19 AM
Jacques3 Jacques3 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 57 Jacques3 User rank is Sergeant (500 - 2000 Reputation Level)Jacques3 User rank is Sergeant (500 - 2000 Reputation Level)Jacques3 User rank is Sergeant (500 - 2000 Reputation Level)Jacques3 User rank is Sergeant (500 - 2000 Reputation Level)Jacques3 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 10 h 6 m 14 sec
Reputation Power: 11
Hi,

MySQL tables aren't ordered by default. Tables in the relational database model are mathematical sets, so there is no order. Well, the rows are of course displayed one after another, but that's arbitrary.

If you want to sort the rows in a specific way, you have to add an ORDER BY clause to your SELECT query:

Code:
SELECT
	`id_voice`
	, `id_project`
	, `description`
FROM
	`yourtable`
ORDER BY
	`id_voice` ASC
;

Reply With Quote
  #4  
Old October 13th, 2012, 04:33 AM
claudia23 claudia23 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 3 claudia23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 41 sec
Reputation Power: 0
When I do the query to extract data, I order by id_voice but this is weird as well.
Let's suppose I insert a new entry.
This is put as first in the list, while in many other tables of my db is put as last.
If the tables are "identical" why does it happen for a specific table?

@TASB do you mean insert query?

Thanks

Reply With Quote
  #5  
Old October 13th, 2012, 08:38 AM
Jacques3 Jacques3 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 57 Jacques3 User rank is Sergeant (500 - 2000 Reputation Level)Jacques3 User rank is Sergeant (500 - 2000 Reputation Level)Jacques3 User rank is Sergeant (500 - 2000 Reputation Level)Jacques3 User rank is Sergeant (500 - 2000 Reputation Level)Jacques3 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 10 h 6 m 14 sec
Reputation Power: 11
Quote:
Originally Posted by claudia23
When I do the query to extract data, I order by id_voice but this is weird as well.


What's weird?



Quote:
Originally Posted by claudia23
Let's suppose I insert a new entry.
This is put as first in the list, while in many other tables of my db is put as last.
If the tables are "identical" why does it happen for a specific table?


You haven't understood what I said. Tables in MySQL have no order. They are not lists, and new rows are not inserted at a specific place.

You probably think that because you're using a user interface like phpmyadmin to view your tables. But what this application actually does is perform a SELECT without an ORDER BY clause, so that the rows are displayed in some random order. This is not how the table is structured. The table is an unordered collection. When you want a specific order, you have to add an ORDER BY clause (you can do that in phpmyadmin by clicking on the specific column).

Again: Tables in the relational model have no order. They are just a heap of rows.

Reply With Quote
  #6  
Old October 13th, 2012, 11:20 AM
claudia23 claudia23 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 3 claudia23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 41 sec
Reputation Power: 0
Thanks everybody for the explanation.
My doubts were due to the fact I am use to visualize tables in a certain way and I was scared there was a problem in my Mysql version or something similar.
If you think that everything, I will sleep quite tonight.

Claudia

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > Order entry problem

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap