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 example of MySQL joint table update data

1.MySQL UPDATE JOIN syntax In MySQL, you can use ...

Detailed explanation of three commonly used web effects in JavaScript

Table of contents 1 element offset series 1.1 Off...

CocosCreator Typescript makes Tetris game

Table of contents 1. Introduction 2. Several key ...

Vue uses canvas to realize image compression upload

This article shares the specific code of Vue usin...

Common HTML tag writing errors

We better start paying attention, because HTML Po...

Summarize how to optimize Nginx performance under high concurrency

Table of contents Features Advantages Installatio...

jQuery treeview tree structure application

This article example shares the application code ...

Solution to incomplete text display in el-tree

Table of contents Method 1: The simplest way to s...

Beginners learn some HTML tags (3)

Related articles: Beginners learn some HTML tags ...

JavaScript data transmission between different pages (URL parameter acquisition)

On web pages, we often encounter this situation: ...

Detailed explanation of the underlying encapsulation of Java connection to MySQL

This article shares the Java connection MySQL und...