mysql语法错误

发布于 2024-08-08 00:17:30 字数 269 浏览 8 评论 0原文

我写了这个简单的查询语句:

INSERT INTO merchants 
('firstName','lastName') 
VALUES 
('Bob','Smith') 

听起来很简单,但我不断收到此错误:

`#1064 - 你的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在 ''firstName','lastName' 附近使用的正确语法) 价值观 ('Bob','Smith')' 第 2 行

I wrote this simple query statement:

INSERT INTO merchants 
('firstName','lastName') 
VALUES 
('Bob','Smith') 

Sounds very simple but I keep getting this error:

`#1064 - 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 ''firstName','lastName' )
VALUES
('Bob','Smith' )' at line 2

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吐个泡泡 2024-08-15 00:17:30

您需要删除firstName 和lastName 周围的引号:

INSERT INTO merchants 
(firstName,lastName) 
VALUES 
('Bob','Smith')

列名是标识符,因此不加引号。

编辑:列名可以使用反引号(`)引用,但这仅当您的列名包含特殊字符或与 MySQL 关键字匹配的列名时才需要这样做。

You need to remove the quotes from around firstName and lastName:

INSERT INTO merchants 
(firstName,lastName) 
VALUES 
('Bob','Smith')

Column names are identifiers, and as such are not quoted.

Edit: Column names can be quoted using backticks (`), but this is only necessary if you have column names that contain special characters or column names that match MySQL keywords.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文