MySQL Forums
Forum List  »  Newbie

Re: INSERT function
Posted by: Felix Geerinckx
Date: June 14, 2005 06:25AM

Lewis Moore wrote:

> The problem comes when i delete a record using the delete function. After a row has been deleted
> this is fine, and the data is still displayed correctly on the news page. How when i use INSERT
> function again it insert the new item where the last one was deleted.
>
> So if i had three news items, for example
>
> 1
> 2
> 3
>
> and i delete item 2, and then insert a new item for example 4 is it place where 2 was
>
> 1
> 4
> 3
>
> I understand why it is doing this, something to do with the table Index!

This statement is not correct.


> My question is, can you use the INSERT function to insert data below the last row?! no mader what
> the table index is???

You cannot rely on the insertion order when you select records without an ORDER BY clause. The records in a relational table are unordered by definition.

If you want to get output in a certain order, you need an ORDER BY clause. In your case, this could be

ORDER BY the_name_of_the_column_containing_the_number_of_the_news_items ASC

for a 1 -> n ordering, or DESC for a n -> 1 ordering.

But it would be better to include a timestamp in your table, and ORDER according to that.

--
felix
Please use BBCode to format your messages in this forum.

Options: ReplyQuote


Subject
Written By
Posted
June 14, 2005 05:38AM
Re: INSERT function
June 14, 2005 06:25AM
June 14, 2005 07:28AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.