Caused by: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near"xxxx"at line X
代码如下
START TRANSACTION;
START TRANSACTION;
INSERT INTO A (id, head, name)
SELECT id, head, name
FROM B
WHERE id = #{accountId}
ON DUPLICATE KEY UPDATE id = #{accountId};
SELECT B.id,
B.phone,
B.uuid,
COALESCE(A.name, B.name) AS nickname,
COALESCE(A.head, B.head) AS head,
A.identity
FROM B
LEFT JOIN A
ON B.id = A.id
WHERE B.id = #{accountId}
FOR UPDATE;
COMMIT;
这段sql在 navicat执行是没有问题的,但是在idea中一直报出语法错误
spring:
datasource:
url: jdbc:mysql://localhost:3306/database?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowMultiQueries=true&serverTimezone=Asia/Shanghai
username: xxx
password: xxx
driver-class-name: com.mysql.cj.jdbc.Driver
yml配置文件中 添加 &allowMultiQueries=true 即可