I was wondering how do I drop a column, containing spaces, in mysql. Tried the following, and got the following exceptions:
alter table test17 drop column [added column2];
ERROR 1064 (42000): 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 '[added column2]' at line 1
alter table test17 drop column 'added column2';
ERROR 1064 (42000): 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 ''added column2'' at line 1
alter table test17 drop column (added column2);
ERROR 1064 (42000): 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 '(added column2)' at line 1
Thanks:)
You should try using back ticks ("`") to quote your column name.
ALTER TABLE test17 DROP COLUMN `added column2`;
OR
Without COLUMN word
ALTER TABLE test17 DROP `added column2`;