Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why this query throwing error while inserting record

Tags:

mysql

pdo

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

like image 388
Bhavik Patel Avatar asked Jun 26 '26 19:06

Bhavik Patel


1 Answers

repeat is a reserved keyword

use `repeat` in the insert statement

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');
like image 61
PyQL Avatar answered Jun 29 '26 13:06

PyQL



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!