Sunil Sahu
Sunil Sahu

Reputation: 23

code: 'ER_PARSE_ERROR', errno: 1064, sqlMessage: "You have an error in your SQL syntax;

I'm making an API and although all the syntax and the query fired is correct but it is showing me

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'

My code

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

'load' is the table name in my MySQL database and I want to fetch everything from there.

Upvotes: 1

Views: 6231

Answers (1)

Rup
Rup

Reputation: 34408

LOAD is a reserved word in MySQL, as part of LOAD DATA or LOAD XML. If you want to use 'load' as a table name you'll have to quote it with backticks:

select * from `load`

Upvotes: 2

Related Questions