Reputation: 44066
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;
Upvotes: 5
Views: 357
Reputation: 13901
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'
Upvotes: 8
Reputation: 69973
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')
Upvotes: 6
Reputation: 12604
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'
Upvotes: 2
Reputation: 425341
INSERT
INTO category (CategoryName, Category, Status, `Order`)
VALUES ('Hardware_1', 'HARDWARE', 1, 1)
Upvotes: 3