Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql Sequalize bulkCreate导致的Sql错误。但是为什么呢?_Mysql_Sql_Insert - Fatal编程技术网

Mysql Sequalize bulkCreate导致的Sql错误。但是为什么呢?

Mysql Sequalize bulkCreate导致的Sql错误。但是为什么呢?,mysql,sql,insert,Mysql,Sql,Insert,此sql查询由bulkCreate从squelize创建。但这有什么不对呢?为什么会出现这种情况 code: 'ER_PARSE_ERROR', errno: 1064, sqlState: '42000', sqlMessage: "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the righ

此sql查询由bulkCreate从squelize创建。但这有什么不对呢?为什么会出现这种情况

code: 'ER_PARSE_ERROR',
    errno: 1064,
    sqlState: '42000',
    sqlMessage: "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1",
    sql: "INSERT INTO `account` (`updatedAt`) VALUES ('2021-05-18 11:00:28'),('2021-05-18 11:00:28'),('2021-05-18 11:00:28'),('2021-05-18 11:00:28'),('2021-05-18 11:00:28') ON DUPLICATE KEY UPDATE;",
    parameters: undefined
  },
  sql: "INSERT INTO `account` (`updatedAt`) VALUES ('2021-05-18 11:00:28'),('2021-05-18 11:00:28'),('2021-05-18 11:00:28'),('2021-05-18 11:00:28'),('2021-05-18 11:00:28') ON DUPLICATE KEY UPDATE;",
  parameters: undefined
}

您不能在重复密钥更新时使用空

在其中使用任何假赋值-例如,
id=id
,其中
id
是表的主键。或者
updatedAt=updatedAt

但是使用
INSERT IGNORE
更简单:

INSERT IGNORE INTO `account` (`updatedAt`) 
VALUES ('2021-05-18 11:00:28'),
       ('2021-05-18 11:00:28'),
       ('2021-05-18 11:00:28'),
       ('2021-05-18 11:00:28'),
       ('2021-05-18 11:00:28');
INSERT IGNORE
如果违反了唯一约束,将生成警告而不是错误,并插入其余行

在这种情况下,根本不需要在重复密钥更新时执行


PS.在定义为唯一的列中插入5个相等值的原因是什么?

我看不懂那微小的图像文本。。。复制并粘贴它,并正确设置格式。@jarlh抱歉,完成:)您使用的是哪种dbms?mysql 8/maria DBS您不需要指定重复密钥更新值吗?