Solution to mysql error code 1064

Solution to mysql error code 1064

If the words in the sql statement conflict with the keywords of mysql, just use `` (above the tab key) to enclose the words.

The original sql statement

<insert id="insert" parameterType="com.zhangman.manman.entity.User" >
 insert into user (id, username, password, name, desc, email, birthday, phone, status, createtime, roleId)
 values ​​(#{id,jdbcType=INTEGER}, #{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, 
  #{name,jdbcType=VARCHAR}, #{desc,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, 
  #{birthday,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, 
  #{createtime,jdbcType=DATE}, #{roleid,jdbcType=INTEGER})
 </insert>

Corrected SQL (note that the field and table names are enclosed in ``)

<insert id="insert" parameterType="com.zhangman.manman.entity.User" >
  INSERT INTO `user`
   (username, `password`, `name`, `desc`, email, birthday, phone, `status`, createtime, roleId)
   VALUES (#{username}, #{password},#{name}, #{desc},#{email},
    #{birthday}, #{phone}, #{status},
    #{createtime}, #{roleid})
 </insert>

Supplement: MySql ERROR 1064 (42000) Same error, different solution

The code at the beginning is this:

Then run:

There is nothing wrong with the code, but why is it wrong? After spending 2 hours on it I finally found the answer.

I didn't add the semicolon!!!!!

Modified code:

Then run again:

Once again I feel despair at my own ignorance and carelessness! ! !

The above is my personal experience. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM. If there are any mistakes or incomplete considerations, please feel free to correct me.

You may also be interested in:
  • Detailed explanation of the usage of MySQL memory tables and temporary tables
  • Some problems you may encounter when installing MySQL
  • Solve the problem of no my.cnf file in /etc when installing mysql on Linux
  • MySQL select results to perform update example tutorial
  • MYSQL slow query and log settings and testing
  • The difference between MySQL user management and PostgreSQL user management

<<:  HTML table tag tutorial (13): internal border style attributes RULES

>>:  Implementation of automatic completion of Docker commands

Recommend

Detailed explanation of how Nginx works

How Nginx works Nginx consists of a core and modu...

Implementation of Nginx load balancing cluster

(1) Experimental environment youxi1 192.168.5.101...

Detailed explanation of Mysql's concurrent parameter adjustment

Table of contents Query cache optimization Overvi...

Implementation of react routing guard (routing interception)

React is different from Vue. It implements route ...

Sample code for making desktop applications with vue + Electron

1.vue packaging Here we use the vue native packag...

Vue template compilation details

Table of contents 1. parse 1.1 Rules for intercep...

The easiest way to debug stored procedures in Mysql

A colleague once told me to use a temporary table...

MYSQL's 10 classic optimization cases and scenarios

Table of contents 1. General steps for SQL optimi...

Basic knowledge: What does http mean before a website address?

What is HTTP? When we want to browse a website, w...

Summary of the dockerfile-maven-plugin usage guide

Table of contents pom configuration Setting.xml c...

A brief discussion on the differences between FTP, FTPS and SFTP

Table of contents Introduction to FTP, FTPS and S...

Summary of all HTML interview questions

1. The role of doctype, the difference between st...