Solution to mysql error code 1064: 1. Check whether the column name uses backticks or single quotes; 2. Modify the statement to "INSERT INTO t_user (`username`, `password`, `email`) VALUES ('admin', 'admin', 'admin@atguigu.com' );" That's it.
The operating environment of this tutorial: Windows 10 system, MySQL version 5.7, Dell G3 computer.
How to solve mysql error code 1064?
SQL query 1064 error [ERR] 1064 - You have an error in your SQL syntax; check the manual....
1064 problem occurs when creating a MySQL table
SQL Statement
DROP DATABASE IF EXISTS bookstore; DROP DATABASE bookstore; USE bookstore; CREATE TABLE t_user ( 'id' INT PRIMARY KEY auto_increment, 'username' VARCHAR ( 20 ) NOT NULL UNIQUE, 'password' VARCHAR ( 32 ) NOT NULL, 'email' VARCHAR ( 200 ) ); INSERT INTO t_user ( 'username', 'password', 'email' ) VALUES ( 'admin', 'admin@atguigu.com' ); SELECT * FROM t_user;
Each sentence is not difficult to understand, but it is because of the input error in the format. It looks the same, but the symbols are wrong. When creating the id username password email, something similar to a single quotation mark was entered incorrectly, and the SQL statement could not be executed.
[ERR] 1064 - You have an error in your SQL syntax; check the manual.......
Solution:
1. This problem is a syntax error in MySql , in MySQL, in order to distinguish MySQL keywords from ordinary characters, MySQL introduces a backtick.
In the above sql statement, if **`the column name does not use backticks` or `the column name uses single quotes`, this error will be reported**.
2. Anti-single quotation mark position: No matter what input method, **switch to English mode, under the Esc key in the upper left corner, above the Tab key, and to the left of the number 1 key, you can type back quotes**, Chinese The status is a small dot
3. What needs to be noted is: in `INSERT INTO t_user (`username`, `password`, `email`) VALUES ('admin', 'admin', 'admin @atguigu.com' ) ;The values in `values are not in backticks, but single quotes, which is easy to confuse.
DROP DATABASE IF EXISTS book_store; CREATE DATABASE book_store; USE book_store; CREATE TABLE t_user ( `id` INT PRIMARY KEY auto_increment, `username` VARCHAR ( 20 ) NOT NULL UNIQUE, `password` VARCHAR ( 32 ) NOT NULL, `email` VARCHAR ( 200 ) ); INSERT INTO t_user ( `username`, `password`, `email` ) VALUES ( 'admin', 'admin', 'admin@king.com' ) ; SELECT * FROM t_user;
Recommended learning: "MySQL Video Tutorial"
The above is the detailed content of How to solve mysql error code 1064. For more information, please follow other related articles on the PHP Chinese website!