首頁 >後端開發 >php教程 > 帮小弟我看看这句insert语句有什么错

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

WBOY
WBOY原創
2016-06-13 13:26:54805瀏覽

帮我看看这句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');
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn