当前位置:Gxlcms > PHP教程 > 帮小弟我看看这句insert语句有什么错

帮小弟我看看这句insert语句有什么错

时间:2021-07-01 10:21:17 帮助过:11人阅读

帮我看看这句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`

------解决方案--------------------
探讨

MySQL的话这样
insert into `chinaipv4` (`from`,`to`) values ('1.50.0.0','1.50.255.255');

人气教程排行