Tag Archives: mybaitisplus

Bulk Update Error: #Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the m

Error:
mybatis plus foreach batch insert is OK. Change it to update and keep reporting errors. It is OK to copy the SQL and execute it separately.
reason:
the insert statement supports batch and can be written in one statement:

INSERT INTO table_name (column1,column2,column3,...) VALUES (value1,value2,value3,...), (value1,value2,value3,...), (value1,value2,value3,...), (value1,value2,value3,...), (value1,value2,value3,...),(value1,value2,value3,...);

Update does not support batch. There are multiple statements corresponding to cyclic batch

update table set c1=v1;
update table set c1=v2;
update table set c1=v3;
.
.
.
update table set c1=v...;

Mybatis does not support executing multiple statements (multiple semicolons) by default
solution:
add the allowmultiqueries = true parameter to the database connection

Allowmultiqueries = true function:
1. You can carry semicolons after SQL statements to realize multi statement execution
2. You can execute batch processing and issue multiple SQL statements at the same time