gpt4 book ai didi

mysql - ERROR 1064 (42000) - 找不到 SQL 查询中的错误

转载 作者:行者123 更新时间:2023-11-29 01:15:44 25 4
gpt4 key购买 nike

我有一个名为 networks 的表:

mysql> describe networks;
+-------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| range | varchar(45) | NO | | NULL | |
+-------+-------------+------+-----+---------+----------------+

我正在尝试使用以下查询在此表中INSERT 值:

INSERT INTO networks(range) VALUES("10.10.10.10/24");

但是我得到这个错误:

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 'range) VALUES("10.10.10.10/24")' at line 1

我尝试使用引号(将它们从 "更改为 ',以及类似的东西),但是它没有用。有什么想法可能是错误的吗?

最佳答案

您可以使用以下INSERT:

INSERT INTO `networks` (`range`) VALUES ('10.10.10.10/24');

您可以将表名和列名括在反引号中,以避免与 MySQL 上的保留字发生冲突。在您的情况下 RANGE 是一个保留字,不能用作没有反引号的列或表名。字符串值应该用单引号括起来。

Note: You should avoid using reserved words like RANGE as column and table definition. You can find a list of all reserved words on the official docs.

关于mysql - ERROR 1064 (42000) - 找不到 SQL 查询中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47200258/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com