对于我的生活,我似乎可以想出来
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;
答案 0 :(得分:8)
Order
是保留字。如果您打算使用它,请在反引号中附上订单。
INSERT INTO category SET CategoryName = 'Hardware_1',
Category = 'HARDWARE', Status = '1', `Order` = '1'
答案 1 :(得分:6)
正如Cfreak在评论中指出的那样,您的语法是有效的。这是你使用未转义的Order关键字的问题。
Insert Into category (CategoryName, Category, Status, `Order`)
Values ('Hardware_1', 'HARDWARE', '1', '1')
答案 2 :(得分:3)
INSERT
INTO category (CategoryName, Category, Status, `Order`)
VALUES ('Hardware_1', 'HARDWARE', 1, 1)
答案 3 :(得分:2)
order是sql中的保留字,您可能需要转义该列名:
INSERT INTO category SET CategoryName = 'Hardware_1', Category = 'HARDWARE', Status = '1', [Order] = '1'