How to change the column position of MySQL table without losing column data?
If you are using MySQL workbench,
- Right-click on table
- Alter table
- drag columns and re-order
- click apply and finish
Try this:
ALTER TABLE table_name MODIFY password varchar(20) AFTER id
Hearaman's answer is correct; but if you are using phpMyAdmin, there is a visual and practical way to do that.
- Open the table
- Choose the "Structure" tab
- Click on "Move columns"
- Drag and drop column names