帮我看看这句insert语句有什么错?
执行这条语句insert into chinaipv4 (from,to) values ('1.50.0.0','1.50.255.255');
总是提示:
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 'from,
to) values ('1.50.0.0','1.50.255.255')' at line 1
表结构如下:
+-------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| from | varchar(16) | YES | | NULL | |
| to | varchar(16) | YES | | NULL | |
+-------+-------------+------+-----+---------+----------------+
------解决方案--------------------
MySQL的话这样
insert into `chinaipv4` (`from`,`to`) values ('1.50.0.0','1.50.255.255');
------解决方案--------------------
from 是 mysql 保留字,挪作他用时需转义 `from`
------解决方案--------------------