为什么这个查询在插入记录时抛出错误

时间:2021-08-31 15:17:17

i have created one table using following query

我使用以下查询创建了一个表

CREATE TABLE `events` (
 `event_id` bigint(20) NOT NULL AUTO_INCREMENT,
 `username` varchar(50) NOT NULL,
 `event_name` varchar(100) NOT NULL,
 `description` text,
 `event_date` datetime NOT NULL,
 `repeat` tinyint(4) NOT NULL,
 `share` varchar(100) DEFAULT NULL,
 `share_type` varchar(50) NOT NULL,
 PRIMARY KEY (`event_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1

and now i am trying to insert record using this query

现在我尝试使用这个查询插入记录

INSERT INTO events (username,event_name,description,event_date,repeat,share,share_type) VALUES ('bhavik','Will go home','','2012-11-11 18:10','0','','public');

error i am getting #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 'username,event_name,description,event_date,repeat,share,share_type) VALUES ('bha' at line 1

我得到#1064 -您的SQL语法有错误;检查与MySQL服务器版本对应的手册,找到正确的语法,以便在第1行使用“用户名、event_name、description、event_date、repeat、share、share_type”值(“bha”)

1 个解决方案

#1


4  

repeat is a reserved keyword

重复是一个保留的关键字

use `repeat` in the insert statement

在insert语句中使用“repeat”。

INSERT INTO events (username,event_name,description,event_date,`repeat`,share,share_type) VALUES ('bhavik','Will go home','','2012-11-11 18:10','0','','public');

#1


4  

repeat is a reserved keyword

重复是一个保留的关键字

use `repeat` in the insert statement

在insert语句中使用“repeat”。

INSERT INTO events (username,event_name,description,event_date,`repeat`,share,share_type) VALUES ('bhavik','Will go home','','2012-11-11 18:10','0','','public');