homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

MYSQL table NOT sorted create

 9:38 am on Mar 13, 2012 (gmt 0)

I wish to create a table. using MYSQL and which content of one field will be imported from an external file. I wish to always be able to keep its original format of this field, i.e I can always recreate the original order in the data was entered, even after some sorting of various other fields.

Will be very grateful for your help



 3:41 pm on Mar 13, 2012 (gmt 0)

If you use an auto_increment field, it will increment that field in the order you insert it and if it's set as the primary key will be the default sorting. So

record 1
record 2
record 3
record 4

create table test (id int(11) primary key auto_increment, textfield text)

then via automation or import or whatever,

insert into test (textfield) values ('record 1');
insert into test (textfield) values ('record 2');
insert into test (textfield) values ('record 3');
insert into test (textfield) values ('record 4');

should produce

1|record 1
2|record 2
3|record 3
4|record 4

so select textfield from test (without ordering) should output them in that order.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved