Home » Open Source » MySQL » way to inserting data into a MYSQL table data in an ordered way
way to inserting data into a MYSQL table data in an ordered way [message #556112] Thu, 31 May 2012 06:16 Go to next message
Cole001
Messages: 1
Registered: April 2012
Location: Ahmedabad, Gujarat, India
Junior Member
Hello all,

I'd like to know if there is a way to insert into a MYSQL table data in an ordered way?
Right now as a workaround I've literally made a table of questions with questionID as primary key, nextQuestion and prevQuestion pointing to other questionIDs. Basically I've made a two way linked list from scratch. Is there anything built into MYSQL that implements this?

Thanks in advance.
Re: way to inserting data into a MYSQL table data in an ordered way [message #556186 is a reply to message #556112] Thu, 31 May 2012 14:54 Go to previous messageGo to next message
Littlefoot
Messages: 21805
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
I don't use MySQL. However, if it is anything like Oracle, there's no use in storing records in an ordered way; ORDER BY - when selecting data from a table - should be used to retrieve record in a desired order. Because, records may be modified - bunch of them deleted from a table, some of them added, then added some more and deleted a few. Insert order will break, sooner or later. Therefore, the ORDER BY clause is the only certain way to get records sorted.
Re: way to inserting data into a MYSQL table data in an ordered way [message #563920 is a reply to message #556186] Fri, 17 August 2012 23:46 Go to previous messageGo to next message
ritu7verma
Messages: 1
Registered: August 2012
Location: India
Junior Member
absolutely correct @littlefoot

can u please tell me which one is better-MYSQl or oracle????
Re: way to inserting data into a MYSQL table data in an ordered way [message #563923 is a reply to message #563920] Sat, 18 August 2012 00:43 Go to previous messageGo to next message
Michel Cadot
Messages: 68617
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Better towards which criteria?

Regards
Michel
Re: way to inserting data into a MYSQL table data in an ordered way [message #563938 is a reply to message #563923] Sat, 18 August 2012 09:41 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>I'd like to know if there is a way to insert into a MYSQL table data in an ordered way?
yes, but it makes no sense to do so
>Right now as a workaround I've literally made a table of questions with questionID as primary key, nextQuestion and prevQuestion pointing to other questionIDs.
For some obscure definition of "work around"
Realize that by doing so when you want to add a new question other than at the "top" or "bottom" of the list,
the application is required to do one INSERT & two UPDATE for every new row.
>Basically I've made a two way linked list from scratch.
& what exactly is gained by doing so?
>Is there anything built into MYSQL that implements this?
No since linked list is not directly support by the standard SQL language upon which all RDBMS are based.
Re: way to inserting data into a MYSQL table data in an ordered way [message #565769 is a reply to message #556112] Thu, 06 September 2012 10:47 Go to previous message
Shenbagaramanm
Messages: 3
Registered: September 2012
Location: Chennai
Junior Member

Just index the table...
Previous Topic: Recover innodb table and data using frm and ibd file
Next Topic: File data without -INFILE
Goto Forum:
  


Current Time: Mon Mar 18 23:57:44 CDT 2024