包含名为“order”的列的查询出现查询错误

发布于 2024-10-01 11:35:49 字数 594 浏览 0 评论 0原文

对于我的一生,我似乎能弄清楚

INSERT INTO category SET CategoryName = 'Hardware_1',
Category = 'HARDWARE', Status = '1', Order = '1'

 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 'Order = '1'' at line 1

CREATE TABLE `category` (
  `CategoryID` int(11) NOT NULL AUTO_INCREMENT,
  `CategoryName` varchar(255) NOT NULL,
  `Category` varchar(255) NOT NULL,
  `Status` tinyint(4) NOT NULL,
  `Order` int(11) NOT NULL,
  PRIMARY KEY (`CategoryID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

For the life of me i can seem to figure it out

INSERT INTO category SET CategoryName = 'Hardware_1',
Category = 'HARDWARE', Status = '1', Order = '1'

 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 'Order = '1'' at line 1

CREATE TABLE `category` (
  `CategoryID` int(11) NOT NULL AUTO_INCREMENT,
  `CategoryName` varchar(255) NOT NULL,
  `Category` varchar(255) NOT NULL,
  `Status` tinyint(4) NOT NULL,
  `Order` int(11) NOT NULL,
  PRIMARY KEY (`CategoryID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

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

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

发布评论

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

评论(4

年少掌心 2024-10-08 11:35:49

Order 是保留字。如果您打算使用 Order,请用反引号将其括起来。

INSERT INTO category SET CategoryName = 'Hardware_1',
Category = 'HARDWARE', Status = '1', `Order` = '1'

Order is a reserved word. Enclose Order in backticks if you intend to use it.

INSERT INTO category SET CategoryName = 'Hardware_1',
Category = 'HARDWARE', Status = '1', `Order` = '1'
把人绕傻吧 2024-10-08 11:35:49

正如 Cfreak 在评论中指出的那样,您的语法是有效的。问题在于您对未转义的 Order 关键字的使用。

Insert Into category (CategoryName, Category, Status, `Order`)
Values ('Hardware_1', 'HARDWARE', '1', '1')

As Cfreak pointed out in the comments, your syntax is valid. It's your use of the unescaped Order keyword that is the issue.

Insert Into category (CategoryName, Category, Status, `Order`)
Values ('Hardware_1', 'HARDWARE', '1', '1')
放我走吧 2024-10-08 11:35:49
INSERT
INTO    category (CategoryName, Category, Status, `Order`)
VALUES  ('Hardware_1', 'HARDWARE', 1, 1)
INSERT
INTO    category (CategoryName, Category, Status, `Order`)
VALUES  ('Hardware_1', 'HARDWARE', 1, 1)
一张白纸 2024-10-08 11:35:49

order 是 sql 中的保留字,您可能需要转义该列名:

INSERT INTO category SET CategoryName = 'Hardware_1', Category = 'HARDWARE', Status = '1', [Order] = '1'

order is a reserved word in sql, you proably need to escape that column name:

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