Reputation: 530
I'm trying to alter a table, and tried to add lat and long values to the database. The lat did fine and is added, however when I try to add the long column MySQL throws an error with the exact same query.
ALTER TABLE for lat:
ALTER TABLE region ADD lat varchar(255) DEFAULT 58.388910;
ALTER TABLE for long:
ALTER TABLE region ADD long varchar(255) DEFAULT 3.666819;
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 'long varchar(255)' at line 1
Why is adding a lat column no problem, but long is? I really need the name to be exactly long
.
Upvotes: 1
Views: 916
Reputation: 872
Long is default text in mysql
ALTER TABLE region ADD long varchar(255) DEFAULT 3.666819;
Replace to
ALTER TABLE region ADD longi varchar(255) DEFAULT 3.666819;
Upvotes: -1
Reputation: 72225
LONG
is a reserved word. Try enclosing it in '`':
ALTER TABLE region ADD `long` varchar(255) DEFAULT 3.666819;
or use another name:
ALTER TABLE region ADD lng varchar(255) DEFAULT 3.666819;
Upvotes: 5