View Full Version : change rows position in mysql
nammem
12-13-2008, 08:46 AM
i want to change the position of a row,is there a way for doing in php myadmin.my sql syntax is also ok
thanks
abduraooft
12-13-2008, 08:51 AM
Why do you need to change the position? You could use the order by clause on selected columns to retrieve the rows in the required order.
nammem
12-13-2008, 12:01 PM
ok but actually i need to change the position of the row is there a way
guelphdad
12-13-2008, 03:30 PM
can you explain why you need to change the "position" of the row? you aren't working with a flat file. without an order by clause a query has no order returned from the tables.
nammem
12-13-2008, 04:03 PM
thanks for the replys ,actually i want a table for storing my class mates details in a default order actually i had created one and unknowingly i had deleted one row ie)name .in phpmyadmin.so wen i inserted one its appending at the last .but i need in the near middle.
so please tell is there a way to do this
CFMaBiSmAd
12-13-2008, 04:54 PM
Why do you need the new name near the middle of the data? Alphabetically his name is near the middle? He's your middle best friend?
The point of using a database is it allows the actual data to be stored and retrieved in the most efficient and quickest way without regard to what that data actually is. It is not important to the database that there are gaps or in what row the information is stored in the database.
The order you retrieve data in is determined by an ORDER BY statement in your query. If you want the data alphabetically by name, you write a query to order it by the name column. If you want the data retrieved by a ranking, you create a column that holds the rank and you write a query to order it by the rank column. You don't use the order of the rows to do these things.
nammem
12-14-2008, 03:10 AM
thanks for giving these much possibilities.but its very easy task for me if i had changed the position of row .so please tell the way to do that
thanks
guelphdad
12-14-2008, 07:30 AM
I don't think you understand how tables work.
database tables don't have rows in them like you are thinking. they are not flat files. you can specify a ranking column and assign values to that ranking column and then use an order by clause on that ranking column to give you a specific order to your table.
without using an order by clause there is no guarantee what order your results will be returned in.
so it isn't a matter of us not telling you what you want, it is that you are thinking of your problem in a way that you shouldn't be.
if you want a flat file structure, use flat files, or take the time to use an order by clause in your queries.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.