View Single Post

   
  #11 (permalink)  
Old 02-28-2008, 07:06 AM
Techie Guy
 
Posts: n/a
Default Re: php/mysql query insert values into enters the records in reverse order

On Tue, 01 Nov 2005 18:09:27 +0100, Christian Kirsch <ck@bru6.de>
wrote:

>Techie Guy wrote:
>
>>
>> Yes I read the post and clearly understand that it doesn't matter
>> generally, what order data is entered into most databases.
>>
>> However in this case there are over 5000 records already in the
>> correct order in the database and it would be nice to keep them that

>
>May be you *read* the posting, but then you refuse to *understand*.
>THERE IS NO ORDER in a MySQL database.
>
>> way.

>
>Since there is no order, you can't keep it.


Oh but yes you can

Existing database contents over 5000 records order by ID DESC

ID, REF, field3, field4, field5
5067, IN005067, data3, data4, data5
5066, IN005066, data3, data4, data5
5065, IN005065, data3, data4, data5
5064, IN005064, data3, data4, data5
n
1, IN000001, data3, data4, data5


Txt file contents with no ID field
IN005071, data3, data4, data5
IN005070, data3, data4, data5
IN005069, data3, data4, data5
IN005068, data3, data4, data5


Database after contents of txt file written by script
ID and REF no longer correspond so when you query ID 5071 REF IN005068
is returned as the record

ID, REF, field3, field4, field5
5071, IN005068, data3, data4, data5
5070, IN005069, data3, data4, data5
5069, IN005070, data3, data4, data5
5068, IN005071, data3, data4, data5
5067, IN005067, data3, data4, data5
5066, IN005066, data3, data4, data5
5065, IN005065, data3, data4, data5
5064, IN005064, data3, data4, data5
n
1, IN000001, data3, data4, data5

However if data was entered in reverse order from the txt file.
the data would look like this
ID, REF, field3, field4, field5
5071, IN005071, data3, data4, data5
5070, IN005070, data3, data4, data5
5069, IN005069, data3, data4, data5
5068, IN005068, data3, data4, data5
5067, IN005067, data3, data4, data5
5066, IN005066, data3, data4, data5
5065, IN005065, data3, data4, data5
5064, IN005064, data3, data4, data5
n
1, IN000001, data3, data4, data5

If you now query ID 5071 it returns REF IN005071

Therefore the order the data is written affect results of previously
written scripts



Reply With Quote