Can I change row order in MySQL Database?
Can I change row order in MySQL Database?
Hi,
I have a simple MySQL database and I am working on it through phpMyAdmin. I have a couple of rows and I was wondering if it is possible to change the order of the rows.
Thanks.
I have a simple MySQL database and I am working on it through phpMyAdmin. I have a couple of rows and I was wondering if it is possible to change the order of the rows.
Thanks.
Re: Can I change row order in MySQL Database?
In what way? When selecting? Or just the id?
Re: Can I change row order in MySQL Database?
By default the rows are ordered by the ID so to reorder them you can change that.
Re: Can I change row order in MySQL Database?
Well, the table has 5 rows in the following order now:
ID
content
title
name
date
So, can I change this order to have something like:
ID
title
name
content
date
without deleting and recreating them? Not so important but just wondering.
ID
content
title
name
date
So, can I change this order to have something like:
ID
title
name
content
date
without deleting and recreating them? Not so important but just wondering.
Re: Can I change row order in MySQL Database?
Those are columns ... and as far as I know there is no war to change the order
Re: Can I change row order in MySQL Database?
Download HeidiSQL (assuming you're using Windows). It's a free database management application (I use it a lot and really like it). It supports re-ordering columns.
Re: Can I change row order in MySQL Database?
Sorry, my bad, I should say columns and thanks for your opinion.jacek wrote:Those are columns ... and as far as I know there is no war to change the order
libeco, thanks for the suggestion, never heard of that application before but it seems nice. I will definitely try it on my localhost, but my hosting account has phpmyadmin and I have to use it.
Re: Can I change row order in MySQL Database?
phpmyadmin is just an interface. If your host supports remote connections you can still use HeidiSQL.
Re: Can I change row order in MySQL Database?
I downloaded HeidiSQL and using it on localhost. Do you know how to import a database? It has "Import > Load SQL File" option but that doesn't import the database to my local mysql server.libeco wrote:phpmyadmin is just an interface. If your host supports remote connections you can still use HeidiSQL.
Re: Can I change row order in MySQL Database?
If you hit the Execute SQL (F9) button it will execute the SQL.
Re: Can I change row order in MySQL Database?
Thank you libeco, it's ok now. But it seems it doesn't directly import a database. It requires a database to be created and selected so that it can import the SQL query and populate the database.libeco wrote:If you hit the Execute SQL (F9) button it will execute the SQL.
Re: Can I change row order in MySQL Database?
I tested it this afternoon and it worked for me. Make sure there's a create statement if you want the database created. Here's my test script if you want to try:
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; -- -- Database: `test123` -- CREATE DATABASE `test123` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; USE `test123`; CREATE TABLE `bla` ( `asd` varchar(5) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
Re: Can I change row order in MySQL Database?
Databases do not store data in any particular order, it is up to you to write your select statements in such a way the the data is retrieved in the order you want.
My aim is to put down on paper what I see and what I feel in the best and simplest way.