Jump to content

How Do I Rearrange Fields In A Mysql Table


creacon

Recommended Posts

In PHP, make a new table with the fields in the desired order, then loop through all the rows of the existing table, making the correct assignments.Are you sure you need to do this? The only purpose I can think of is to prepare for exportation into csv/tsv format.

Link to comment
Share on other sites

In PHP, make a new table with the fields in the desired order, then loop through all the rows of the existing table, making the correct assignments.Are you sure you need to do this? The only purpose I can think of is to prepare for exportation into csv/tsv format.
If that is the only reason to do so, simply write to the csv file instead of the new table.And the DB with the new table will get messed up if the new table doesn't use the old id numbers (assuming one might be auto-increment).Consider that this is not a highly recommended procedure unless you absolutely have to do it.Why do you need the data re-sorted?
Link to comment
Share on other sites

Thanks a bunch for all your input. It has certainly given me food for thought, so I'm going to find a different way to do what I need to do.I'm converting my web questionnnaire (2 pages) to a .pdf, using FPDF. I have two table, one containing the answers to the questionnaire, and the other is the static text for it. I thought that if the fields in the tables were in the same sequence as they appear on the web pages, I could simply make a "for" loop merging the text with the variables into the .pdf document; in other words I was being lazy. When I was in the Air Force eons ago, I had a commander who believed that whenever there was a new job to be done, he'd assign it to the laziest man in the outfit, because he'd be sure to find the quickes way to get it done. I used to get an awful lot of new jobs there.This problem was, of course, my stupidity in laying out the table structure; I laid it out the way I was used to doing for local programming to optimize access to the most significant columns, instead of realizing what I needed to do to email the questionnaire to the qualifying agency.If, in my SELECT statement, I specify the fields in the order I wan them, will they actually come to me in that sequence? If so, that could be an answer.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...