Sunday, 16 April 2017

SQL Parse Error NodeJS

I'm using node-mysql library for my web application. Currently I successfully batch inserts the data into database using array approach. I had issue when I start to add another parameter('order') to the data. It returns SQL Parsing error.

CODE

var arr = [['id2','d_id2','title',2,0],['id3','d_id3','title2',2,1],['id4','d_id4','title3',2,2]];
connection.query('INSERT INTO table (id,d_id, title, select, order) VALUES ?', [arr], function(err,result)
{ //result produces undefined });

SQL Table Structure

id: varchar(50)
d_id: varchar(50)
title: varchar(50)
select: int(10)
order: int(10)

ERROR

{"code":"ER_PARSE_ERROR","errno":1064,"sqlState":"42000","index":0}



via Foonation

No comments:

Post a Comment