Author Topic: Changing row order in MySQL using phpMyAdmin  (Read 1846 times)

0 Members and 1 Guest are viewing this topic.

Offline jonw118Topic starter

  • Enthusiast
  • Posts: 77
    • View Profile
Changing row order in MySQL using phpMyAdmin
« on: February 17, 2010, 05:15:33 PM »
I have a unique situation where I have a php script that is very complex and I cannot do a simple order by priority. Instead it displays the data on the frontend in the exact order it is stored in the MySQL database.

Is there any way (I've looked high and low!) to change the order that rows appear in the MySQL database. Ideally I'd like for the table to display the table rows in asc order by the column "page_name".

Not sure this is possible to alter the table to achieve this. Does anyone know?

Thanks much for any help!

Offline thorpe

  • Administrator
  • 'Mind Boggling!'
  • *
  • Posts: 29,255
    • View Profile
Re: Changing row order in MySQL using phpMyAdmin
« Reply #1 on: February 17, 2010, 05:43:19 PM »
Quote
I've looked high and low!

You can stop looking.

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.

Quote
I have a php script that is very complex and I cannot do a simple order by priority.

I fail to see why. Can you tell us why you can't?

Offline jonw118Topic starter

  • Enthusiast
  • Posts: 77
    • View Profile
Re: Changing row order in MySQL using phpMyAdmin
« Reply #2 on: February 17, 2010, 06:05:39 PM »
"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."

Yeah I know it's not written/stored in a particular order, and understand it's not flat, but once the data is in there the row location doesn't change. So that's all I'm trying to do is change the order it's stored (or shown in phpMyAdmin)... because the order it is stored is the order it displays on the frontend. But as I feared and as you confirmed there's nothing I can do about that I guess.


"I fail to see why. Can you tell us why you can't?"

It is pulling many different modules menus loading into a centralized menu, the modules are then joined with one another and the module in question displays several different levels of navigation (which needs to be sorted). But the other modules do not need to be sorted. And it is the same statement joining all of these together. I know that sounds confusing, just the way it was written, which I've struggled to dissect and implement an effective order by.
« Last Edit: February 17, 2010, 06:06:22 PM by jonw118 »

Offline thorpe

  • Administrator
  • 'Mind Boggling!'
  • *
  • Posts: 29,255
    • View Profile
Re: Changing row order in MySQL using phpMyAdmin
« Reply #3 on: February 17, 2010, 06:15:04 PM »
Quote
I've struggled to dissect and implement an effective order by.

Why not post your attempts and go from there?

Offline jonw118Topic starter

  • Enthusiast
  • Posts: 77
    • View Profile
Re: Changing row order in MySQL using phpMyAdmin
« Reply #4 on: February 17, 2010, 06:19:03 PM »
Yeah I guess I'll post over in the PHP Forum... my intent with posting on the MySQL forum was hoping there a solution from this angle, which there's not. But thanks much for answering my question, albeit not the answer I wanted, haha.

Offline thorpe

  • Administrator
  • 'Mind Boggling!'
  • *
  • Posts: 29,255
    • View Profile
Re: Changing row order in MySQL using phpMyAdmin
« Reply #5 on: February 17, 2010, 07:24:00 PM »
Quote
Yeah I guess I'll post over in the PHP Forum

if it is a query you are having trouble with the post belongs here.

Offline fenway

  • MySQL Si-Fu / PHP Resident Alien
  • Global Moderator
  • 'Mind Boggling!'
  • *
  • Posts: 15,443
  • Gender: Male
    • View Profile
Re: Changing row order in MySQL using phpMyAdmin
« Reply #6 on: February 23, 2010, 12:53:32 PM »
You need a sortorder column -- nothing more.
:anim_rules: Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.