Reputation: 2047
I am encountering error while updating my table field 'delete' in MySQL
CREATE TABLE IF NOT EXISTS `student` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` text NOT NULL,
`delete` varchar(3) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=29 ;
INSERT INTO `student` (`name`, `delete`) VALUES('newa', 'no')
UPDATE SET delete='yes
#1064 - 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 'set delete-'yes'' at line 1
Upvotes: 0
Views: 115
Reputation: 7779
use `delete` instead of delete. Please do not use reserved words to name tables and columns. You might as well rename the column to is_deleted
.
Upvotes: 0
Reputation: 276
You forgot the table name between UPDATE and SET. You should have UPDATE student SET delete='yes'
Additionally, you shouldn't use reserved keywords as column names.
Upvotes: 0
Reputation: 449395
delete
is a reserved word in mySQL.
You need to wrap the field name in backticks:
SET `delete` = .....
or, preferably, use a different field name.
Upvotes: 1