Home > Software engineering >  mySQL: ERROR 1064 (42000) SQL Insert into
mySQL: ERROR 1064 (42000) SQL Insert into

Time:08-10

Hi I have been struggling with error code 1064(42000) and cant figure what I am doing wrong.

mysql> DESC user;
 ------------ ------------- ------ ----- --------- ---------------- 
| Field      | Type        | Null | Key | Default | Extra          |
 ------------ ------------- ------ ----- --------- ---------------- 
| ID_USER    | int         | NO   | PRI | NULL    | auto_increment |
| FIRST_NAME | varchar(45) | NO   |     | NULL    |                |
| LAST_NAME  | varchar(45) | NO   |     | NULL    |                |
| USERNAME   | varchar(45) | NO   |     | NULL    |                |
| PASSWORD   | varchar(45) | NO   |     | NULL    |                |
| BIRTH      | datetime    | NO   |     | NULL    |                |
| STATUS     | varchar(1)  | NO   |     | NULL    |                |
 ------------ ------------- ------ ----- --------- ---------------- 
7 rows in set (0.03 sec)

mysql> INSERT INTO `USER` (FIRST_NAME, LAST_NAME, USERNAME, `PASSWORD`, BIRTH, `STATUS`)
    -> VALUES ('Mike', 'Smith', 'MSmith', '1234', '1999-01-01', 'A');
ERROR 1064 (42000): 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 'INSERT INTO `USER` (FIRST_NAME, LAST_NAME, USERNAME, `PASSWORD`, BIRTH, `STA' at line 1

I tried without back tick and also with double quotes instead of single but no luck. I appreciate your help.

CodePudding user response:

Try this

INSERT INTO 'USER' ('FIRST_NAME','LAST_NAME','USERNAME','PASSWORD','BIRTH','STATUS') VALUES ('Mike', 'Smith', 'MSmith', '1234', '1999-01-01', 'A');

CodePudding user response:

Quotes are wrong, here is the correct format:

INSERT INTO User (FIRST_NAME, LAST_NAME, USERNAME, PASSWORD, BIRTH, STATUS)
VALUES ('Mike', 'Smith', 'MSmith', '1234', '1999-01-01', 'A');
  • Related