If i am having a table like row1, row2, row3, then when i will add rowX, it will look like row1 row2 row3 rowX can i do something so the rowX to be inserted on the top of the table not on the bottom? like rowX row1 row2 row3
Why you want to insert on the top of the table? If you want to display the data in that sequence then use ORDER BY clause to order the results. It is always not true that new rows are inserted at the end of the table. Try the following and you'll see a different behavior. Insert 3 rows as you inserted before, now delete 2nd row and insert rowX. Now check the data in the table. You'll find that the rows are in this format row1 rowX row3
Because i want to insert it their, not to modify lot's of codes of the already made script + can i also do something to insert the data in the middle of that table? is there a function to change row(X) data with row(Y) data?
You can not insert the data according to your will but you can display it as you want. You can do one thing after inserting data i.e. sort the whole table on a specific field e.g. ALTER TABLE table_name ORDER BY id; Code (markup):
you can export the current rows to .sql, delete all rows, move the row you want on top to the top, import the .sql
Tables have no order--therefore they have no top, bottom, first, thirty-second, nor last. They aren't spreadsheets nor word documents. Think of tables as this huge pile of rows of data all thrown together somewhere in the bowels of a computer that you can't even see. When you add new data it just creates a new record and throws it on that pile without care how it bounces around and lands. Order only exists when you tell your computer to retrieve that data and use the 'ORDER BY' clause of SQL. So, to make your data come out like you want it, you must define what top, bottom means. What field determines order? From there, to manipulate how each record comes out, insert values into that field such that when you use the 'ORDER BY' clause on that field it comes out properly.