<\/script>')

Query error for a query containing a column named "order"

In my life I can figure out how to do it

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;
+5
source share
4 answers

Order- reserved word. Attach the order to the backticks if you intend to use it.

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

As Cfreak pointed out in the comments, your syntax is valid. This is the problem of using the Unescaped Order keyword.

Insert Into category (CategoryName, Category, Status, `Order`)
Values ('Hardware_1', 'HARDWARE', '1', '1')
+6
source
INSERT
INTO    category (CategoryName, Category, Status, `Order`)
VALUES  ('Hardware_1', 'HARDWARE', 1, 1)
+3
source

order is a reserved word in sql, you need to avoid this column name:

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

All Articles