我在这个 MariaDB 查询中遗漏了什么?我现在遇到 SQL 语法错误

What did I miss in this MariaDB query? I'm getting now a SQL syntax error

每次我得到错误:你的 SQL 语法有错误;查看与您的 MariaDB 服务器版本对应的手册,了解在 'by, user, reason, active) VALUES (5, 663403380223377400, 793061601288388600, 274'.

附近使用的正确语法
          connection.query('INSERT INTO modlogs (logtypeid, textchannel, message, by, user, reason, active) VALUES (?, ?, ?, ?, ?, ?, ?)', [5, parseInt(message.channel.id), parseInt(message.id), parseInt(message.author.id), parseInt(mentionedMember.id), reason, 1], (error, results) => {
            if (error) console.log('MariaDB Error: ' + error)
          })

我是否遗漏了查询中的内容?

MariaDB 版本:10.1.47

亲切的问候,

科尔内

by是保留字。

Reserved words cannot be used as Identifiers, unless they are quoted.

https://mariadb.com/kb/en/reserved-words/

“By”是一个保留字,所以它必须被引用才能在您的插入语句中被视为列名。将其更改为“by”,即将其括在反引号中以消除错误。

也就是说,最好避免使用保留字作为 table 或列名。

by是保留字in MySQL and in MariaDB,所以需要引用:

INSERT INTO modlogs (logtypeid, textchannel, message, `by`, `user`, reason, active) 
VALUES (?, ?, ?, ?, ?, ?, ?)

更好的办法是使用不与保留字(或关键字)冲突的标识符。英文单词很多,只有几百个是SQL个关键词。

注意我也引用了user:它不是保留字,而是语言关键字,但是引用它还是个好习惯