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;
The order doesn't matter, actually, so you are free to order them however you'd like. edit: I guess a bit more background is helpful: As far as I know, the process of optimizing any query happens prior to determining exactly what subset of the row data is being pulled.
This means two columns have the same column name — that is the “Name” column. The SQL Machine is confused as to which “Name” out of the two tables you are referring to. It is ambiguous — not clear. To clarify this, add the alias of either or both TABLE1 or TABLE2 to the columns having the same name.
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'
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')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With