1

I am using Express and MYSQL. This is my parameters

 var values = [
      [ 9, 1, 'input_4', 'Rj', 1 ],
      [ 9, 2, 'input_1', 'hk', 1 ],
      [ 9, 3, 'input_2', 'Vk', 1 ]
    ]

This is my Query

INSERT INTO form_meta(form_id,sequence,meta_key,meta_label,is_active) VALUES ?

which is working fine.

No i want if i pass

   var values = [
          [ 9, 1, 'input_4', 'Raj K', 1 ],
          [ 9, 2, 'input_1', 'Kumar', 1 ],
          [ 9, 3, 'input_2', 'Vinit Kumar', 1 ]
        ]

this needs to update not insert I am using this query

 var query = "INSERT INTO `form_meta`(`form_id`,`sequence`,`meta_key`,`meta_label`,`is_active`)

VALUES ? ON Duplicate Key sequence= VALUES(sequence)";

    connection.query(query,[values],cb);

it gives me error

Error: ER_PARSE_ERROR: You have an error in your SQL syntax;

Any Idea?

1 Answers1

0

It should be on duplicate key update sequence=values (sequence)

Naveen
  • 3
  • 3