How do I rearrange fields in a MySQL Table?

Problems with the Windows version of XAMPP, questions, comments, and anything related.

How do I rearrange fields in a MySQL Table?

Postby creacon » 02. December 2009 19:27

I need to rearrange the fields (columns) in two tables in a MySQL database, in order to simplify programming. I've tried everything I can think of in PHPMyAdmin, but can't seem to find the trick. Would someone please tell me how this is done?
creacon
 
Posts: 36
Joined: 21. August 2009 19:14

Re: How do I rearrange fields in a MySQL Table?

Postby Nobbie » 02. December 2009 23:14

SQL Tables do not have any fields order.

The order of the selected fields depends on the Select Statement

SELECT abc, xyz, blabla, blubblubb FROM table ....

So if you like to have a certain order in your fetched rows, simply adapt the Select statements to your needs.
Nobbie
 
Posts: 8779
Joined: 09. March 2008 13:04

Re: How do I rearrange fields in a MySQL Table?

Postby Izzy » 03. December 2009 02:01

Hi Rob,

Here are some web search results that may also help with explaining this issue.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: How do I rearrange fields in a MySQL Table?

Postby meteormatt » 03. December 2009 10:52

creacon wrote:I need to rearrange the fields (columns) in two tables in a MySQL database, in order to simplify programming. I've tried everything I can think of in PHPMyAdmin, but can't seem to find the trick. Would someone please tell me how this is done?

The SQL query may need the Query Brower
Image

Usually I do the arrangment at the mangament work at the MySQL Query Brower.
User avatar
meteormatt
 
Posts: 4
Joined: 13. October 2009 09:10
Location: China

Re: How do I rearrange fields in a MySQL Table?

Postby creacon » 03. December 2009 17:14

Nobbie wrote:SQL Tables do not have any fields order.

The order of the selected fields depends on the Select Statement

SELECT abc, xyz, blabla, blubblubb FROM table ....

So if you like to have a certain order in your fetched rows, simply adapt the Select statements to your needs.


What I'm doing is creating a .pdf document (a questionnaire) from two tables, one containing the text and the other containing the variables. The reason I wanted to have the fields in order is so that I could simply retrieve the data as arrays and, in effect, merge them using a "for" loop. I wanted to use the "SELECT *..." because there are 45 fields, and that would require a lot of typing (admittedly only once), when only about a half dozen of the fields in the variables table are not in the same order as the text table.

From what I've seen in the references you've provided as well as the MySQL Query Browser, all are basically addressing methods for sorting the rows. I'm only dealing with one row at any givend time (i.e. The user fills out the questionnaire and, upon submission, the answers are stored in a MySQL Table for future follow up, but then those same data from the two pages of the questionnaire are then merged into a .pdf [using FPDF] and sent as an email attachment, to another agency which processes the data.

I guess, if there's no way to physically rearrange those half dozen or so fields in the table, perhaps I can find another approach, such as using the questionnaire variables array which, is in the correct sequence, and at the time, is in a session variable. It's an associative array, however, and I don't know if it's allowable to loop through that kind of array referencing the elements by numeric position.

Please tell me that it can be done?!?!?!?
creacon
 
Posts: 36
Joined: 21. August 2009 19:14


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 54 guests