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 MySQL transaction isolation level and MVCC

Table of contents Transaction Isolation Level Pro...

CSS World--Code Practice: Image Alt Information Presentation

Using the <img> element with the default sr...

Selection and thinking of MySQL data backup method

Table of contents 1. rsync, cp copy files 2. sele...

Summary of common tool examples in MySQL (recommended)

Preface This article mainly introduces the releva...

CSS eight eye-catching HOVER effect sample code

1. Send effect HTML <div id="send-btn&quo...

Vue.js application performance optimization analysis + solution

Table of contents 1. Introduction 2. Why do we ne...

How to import Excel files into MySQL database

This article shares with you how to import Excel ...

How to view nginx configuration file path and resource file path

View the nginx configuration file path Through ng...

Nginx handles http request implementation process analysis

Nginx first decides which server{} block in the c...

How to set a fixed IP address in CentOS7 virtual machine

Since my development environment is to install Ce...

Detailed explanation of eight methods to achieve CSS page bottom fixed

When we are writing a page, we often encounter a ...

WeChat applet example of using functions directly in {{ }}

Preface In WeChat applet development (native wxml...

JavaScript anti-shake case study

principle The principle of anti-shake is: you can...