Home >Backend Development >PHP Tutorial > 帮小弟我看看这句insert语句有什么错

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

WBOY
WBOYOriginal
2016-06-13 13:26:54807browse

帮我看看这句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');
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn