Mysql – Question about ‘thesql error 1064’

MySQL

ALTER TABLE sample62 CHANGE newcol c;

This code makes me mad. I just followed the book I had.

Program said

You have an error in your SQL syntax; check the manual that corresponds
to your MySQL server version for the right syntax to use near '' at line 1.

My MySQL version is 5.7. Can you please help me?

Best Answer

mysql error 1064

The error that gets thrown if the syntax is wrong. You did not clearly state what you are doing.

If you are changing a column

ALTER TABLE table_name MODIFY COLUMN column_name datatype

If you are trying to change column definition

ALTER TABLE table_name CHANGE old_column_name new_column_name data_type(size)

If you are adding a new column

ALTER TABLE table_name ADD column_name datatype