当我尝试运行时出现错误1064(42000):
INSERT INTO ips (ip, created_at, lat, long, country, continent, city, postal_code, state) VALUES ('192.168.2.111', '2019-07-19 12:06:2', '40.3444', '50.44', 'test', 'test', 'test', 'test', 'test');
我使用以下命令创建了表:
CREATE TABLE `ips` ( `id` INT NOT NULL AUTO_INCREMENT, `ip` VARCHAR(255), `created_at` DATETIME, `lat` VARCHAR(255), `long` VARCHAR(255), `country` VARCHAR(255), `continent` VARCHAR(255), `city` VARCHAR(255), `postal_code` VARCHAR(255), `state` VARCHAR(255), PRIMARY KEY( `id` ));
我已经尝试使用`而不是'并将其放在各列中来运行它。我在这里缺少明显的东西吗?
答案 0 :(得分:2)
long
是reserved word,必须在反引号中进行转义。试试这个:
INSERT INTO ips (ip, created_at, lat, `long`, country, continent, city, postal_code, state) VALUES ('192.168.2.111', '2019-07-19 12:06:2', '40.3444', '50.44', 'test', 'test', 'test', 'test', 'test');