无法使用Angular和Sequelize在MariaDB SQL Server中运行两个查询(语法错误)

时间:2019-03-26 06:38:12

标签: mysql angular mariadb

我正在尝试从两个不同的表中删除,但是在尝试运行SQL命令时出现错误。 我正在尝试结合这两个查询:

defaultAdapter.query('DELETE FROM reasons WHERE name = :name')
defaultAdapter.query('DELETE rt FROM reason_to_transaction rt INNER JOIN reasons r ON r.id = rt.reason_id WHERE name = :name')

我运行以下代码:

defaultAdapter.query('DELETE FROM reasons WHERE name = :name;DELETE rt, r FROM reason_to_transaction rt INNER JOIN reasons r ON r.id = rt.reason_id WHERE id = :id',

有人可以告诉我Sequelize方法(SQL)中2个查询的正确语法是什么。 当我运行此命令时,出现以下错误:

Unhandled rejection SequelizeDatabaseError: 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 'DELETE rt, r FROM reason_to_transaction rt INNER JOIN reasons r ON r.id = rt.rea' at line 1
    at Query.formatError 

1 个答案:

答案 0 :(得分:0)

不允许您将两个查询合并为一个呼叫。

如果您需要将它们捆绑在一个“事务”中(全部或全部),那么您需要某种形式的START TRANSACTIONCOMMIT