mySQL语法错误

时间:2010-09-30 22:51:21

标签: mysql

 INSERT into error_log 
   (id_user, id_error, severity, date) 
 VALUES 
   ('93, '1', '6', '1285886665')

投掷

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 '1', '6', '1285886794')' at line 4

CREATE TABLE `error_log` (
  `id` int(25) NOT NULL auto_increment,
  `id_user` int(25) NOT NULL,
  `id_error` int(5) NOT NULL,
  `severity` int(2) NOT NULL,
  `date` varchar(50) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

1 个答案:

答案 0 :(得分:4)

使用:

INSERT into error_log 
 (id_user, id_error, severity, `date`) 
VALUES 
 (93, 1, 6, '1285886665')

问题是关于id_user的值的未公开单引号 文本值需要用单引号括起来,例如date列。但是INTegers不需要用单引号括起来,虽然MySQL会隐式地将数据类型转换为列的任何内容......否则会引发错误。