How to change the column position of MySQL table without losing column data?

mysql, sql

Solution

Try this:

ALTER TABLE table_name MODIFY password varchar(20) AFTER id

Problem

I want to change the column positions of my database table without losing data. For example: Current table: ``` +----+------+-------+----------+ | id | name | email | password | +----+------+-------+----------+ ``` to ``` +----+----------+------+-------+ | id | password | name | email | +----+----------+------+-------+ ```

Original source