Hello friends... How can I change the order of the columns ?

e.g. My columns order is:

id
name
lastname

and now I want to change the order of the columns like:

id
lastname
name

Thanks.

1) add two columns newlastname and newname
2) update them with lastname and name
3) drop columns name and lastname
4) rename newlastname to lastname and newname to name

The order of the columns in the database is totally and utterly unimportant. You set the order you wish them to be displayed in in your sql query or in your php code that handles the result.

eg SELECT sname, fname, membnum, age FROM

or SELECT membnum, fname, sname, age FROM

or SELECT membnum, age, sname, fname FROM

And from any of these queries, you could use the php to display as
age, fname, sname, membnum

there is absolutely no need to have the columns in some "order" in the database.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.