【问题标题】:code: 'ER_PARSE_ERROR', errno: 1064, sqlMessage: "You have an error in your SQL syntax;code: 'ER_PARSE_ERROR', errno: 1064, sqlMessage: "你的 SQL 语法有错误;
【发布时间】:2020-12-06 19:56:57
【问题描述】:

我正在制作一个 API,虽然所有语法和触发的查询都是正确的,但它向我展示了

code: 'ER_PARSE_ERROR',
  errno: 1064,
  sqlMessage: "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 'load' at line 1",
  sqlState: '42000',
  index: 0,
  sql: 'select * from load'

我的代码

Router.get("/",(req,res)=>{
    mysqlConnection.query("select * from load",(err,rows,fields)=>{
        if(!err){
            res.send(rows);
        }else{
            console.log(err);
        }
    })
});

'load' 是我的 MySQL 数据库中的表名,我想从那里获取所有内容。

【问题讨论】:

    标签: mysql sql node.js api


    【解决方案1】:

    LOAD 是 MySQL 中的保留字,作为 LOAD DATA 或 LOAD XML 的一部分。如果你想使用 'load' 作为表名,你必须用反引号引用它:

    select * from `load`
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-24
    • 2019-09-01
    • 1970-01-01
    相关资源
    最近更新 更多