Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
exports.addProduct = catchAsyncErrors( async (req,res,next) =>{
    pool.getConnection((err, connection) => {
        console.log('1')
        if(err) throw err
        console.log('2')
        const params = req.body
        connection.query('INSERT INTO product SET ?', params, (err, rows) => {
            console.log('3')
        connection.release() // return the connection to pool
        if (!err) {
            res.send(`product with the record ID  has been added.`)
        } else {
            console.log(err)
        }
        
        console.log('The data from product table are:11 \n', rows)
    
        })
    })
 })


What I have tried:

i don't why this error is occurring even i check manually couple of time but i didn't resolve it 
Posted
Updated 22-Mar-22 0:05am

1 solution

Quote:
SQL
INSERT INTO product SET ?
As the error clearly says, you have an error in your SQL syntax. Read the documentation for the command you are trying to use:

MySQL :: MySQL 8.0 Reference Manual :: 13.2.6 INSERT Statement[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900