Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase 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 Codewalkers Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old August 23rd, 2003, 03:44 AM
nazly nazly is offline
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Colombo,SriLanka
Posts: 1,325 nazly User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 18 sec
Reputation Power: 3
Send a message via Yahoo to nazly
MySQL Select

When I use the SELECT statement without sorting on a table with a PRIMARY KEY, does the result
automatically gets sorted to the asecending order to the field with the PRIMARY KEY???

Also does MySQL hold the information of the records in the manner that were inserted on a table that doesn't contain a PRIMARY KEY???

Reply With Quote
  #2  
Old August 23rd, 2003, 04:20 AM
zombie zombie is offline
Codewalkers Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2007
Location: serbia
Posts: 1,876 zombie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
RE: MySQL Select

1) yes

2) probably


(you can check both of this very easy..)

Reply With Quote
  #3  
Old August 23rd, 2003, 04:39 AM
nazly nazly is offline
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Colombo,SriLanka
Posts: 1,325 nazly User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 18 sec
Reputation Power: 3
Send a message via Yahoo to nazly
RE: MySQL Select

1)OK.

2)Is this Yes Or No? I want to know whether when you perfrom a SELECT query on a table that doesn't contain a PRIMARY KEY, does it sort the records in the Ascending order in the manner it was inserted..

Better if you also can direct me to reference on this with your reply..

Reply With Quote
  #4  
Old August 23rd, 2003, 05:01 AM
bakertrg's Avatar
bakertrg bakertrg is offline
Contributing User
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Scottsdale AZ, US
Posts: 2,253 bakertrg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 48 m 45 sec
Reputation Power: 4
Send a message via Yahoo to bakertrg
RE: MySQL Select

make a little table with 2 fields, insert 5 records with equivalent data in one of the records and the following in the other c, d, e, a, b and see how they are returned. I imagine with no key you get them back either fifo or lifo but you can test this as easy as anyone else can.

Reply With Quote
  #5  
Old August 23rd, 2003, 05:10 AM
nazly nazly is offline
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Colombo,SriLanka
Posts: 1,325 nazly User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 18 sec
Reputation Power: 3
Send a message via Yahoo to nazly
RE: MySQL Select

Quote:
I imagine with no key you get them back either fifo or lifo but you can test this as easy as anyone else can.


I have tested this.. and works OK.. I want to know whether its true in all cases.. Something like a theoritical explanation or whether its mentioned in the manual.. I Don't want to mess up with data

Reply With Quote
  #6  
Old August 23rd, 2003, 05:24 AM
bakertrg's Avatar
bakertrg bakertrg is offline
Contributing User
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Scottsdale AZ, US
Posts: 2,253 bakertrg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 48 m 45 sec
Reputation Power: 4
Send a message via Yahoo to bakertrg
RE: MySQL Select

how do you want the data returned? If you want the data returned in the order it was submitted then ad an auto increment id field and make it a key. If you want the data sorted some other way, sort it in that manner. I would assume that if you tested it and it works one way it will probably continue to work that way but if this is critical stuff why not control it yourself?

Reply With Quote
  #7  
Old August 23rd, 2003, 06:18 AM
nazly nazly is offline
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Colombo,SriLanka
Posts: 1,325 nazly User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 18 sec
Reputation Power: 3
Send a message via Yahoo to nazly
RE: MySQL Select

Yep.. Its kinda mission critical stuff.. I was not aware of using AUTOINCREMENT id fields earlier.. Using them now though to great effect.. What I'm worried is the existing datbases I have.. I was using VARCHAR field types for the id (id being the PRIMARYKEY) and used to generate the id via the code and insert them.. id looks like
'CMK0014','CMK0015',....
As you said it works fine without ORDER BY sorting, probably its automatically sorted in the manner it was inserted.. To generate the new id via the code I used to get the last id and generate the new one.. So far so good I didn't have any problems.. I know what I'm doing now, using AUTOINCREMENT is the best way to do.. Any suggestions to kinda migrate my old method to the current one??

Thanks for both of you zombie and bakertrg..

Reply With Quote
  #8  
Old August 23rd, 2003, 10:12 AM
bakertrg's Avatar
bakertrg bakertrg is offline
Contributing User
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Scottsdale AZ, US
Posts: 2,253 bakertrg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 48 m 45 sec
Reputation Power: 4
Send a message via Yahoo to bakertrg
RE: MySQL Select

yes, you could migrate the code by adding a new field int to the data base, running a for loop to insert a progressively incremented number into that field, change the field to autoincrement. This might work (i.e. the next field will automatically increment) by itself and it might not, I think it does but if it does not and the auto field starts from 1, there is a way to set the autoincrement counter, have to look in the manual for that.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > MySQL Select


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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway