Change column position in mysql table

Many times, we come across the situation where a column needs to be re-position in the table. Either at first position, at last position or  anywhere in the table after some columns. This particular modification can be done using ALTER TABLE queries.

#Position a column at first position
ALTER TABLE table_name MODIFY COLUMN column_name datatype FIRST;
Example : ALTER TABLE events MODIFY COLUMN event_id INT FIRST;
#Position a column after specific column
ALTER TABLE table_name MODIFY COLUMN column_name datatype AFTER another_column;
Example : ALTER TABLE events MODIFY COLUMN event_id INT AFTER event_name;

Welcome to Aaro Scripts!

Welcome to Aaro Scripts. Its all about the web coding, design, code snippets, concepts and lot. Keep visiting daily for new topics. Aaro scripts will main provide the resource for php, css2, css3, html4, html4, javascripts, jquery, magento, codeigniter, etc.

Yes you assumed correct. I am a PHP developer, and i will focus mainly on the solutions related php programming.