0

Novice SQL user here, trying to update an existing database. I am trying to update everything at once with the following query

INSERT INTO `table` (`lots`, `of`, `keys`)
VALUES ('Row', '1', 'data'),
('Row', '2', 'data')
...
('Row', 'n', 'data');

This results in the syntax error

 Syntax error near '' at line n+1

Which I'm not sure how to debug. I see one ten-year oldresult here that suggests that multi-line insertions don't work like this, but the syntax I copied from a csv-to-sql site for a snippet of the database suggests that the way I'm doing it should work.

dougp
  • 2,810
  • 1
  • 8
  • 31
user3517167
  • 137
  • 1
  • 9
  • Some database implement multi-line inserts while others don't. Which database are you using? (looks like MySQL) – The Impaler Jul 13 '23 at 19:49
  • @TheImpaler yes, it is MySQL – user3517167 Jul 13 '23 at 19:56
  • Works for me. See [fiddle](https://dbfiddle.uk/3wNywKI2). Maybe you are reaching some limits of the MySQL interpreter/engine. How many lines are you trying to insert at once? How big are they? – The Impaler Jul 13 '23 at 19:57
  • @TheImpaler fiddle gives the same error message when I try with the real database. The data isn't publicly accessible so unfortunately I can't share the real thing. – user3517167 Jul 13 '23 at 20:04
  • Another idea: If you have values that include single quotes (`'`) remember that they need to be escaped by typing them twice (`''`). – The Impaler Jul 13 '23 at 20:07
  • No, there are none of those fine. But I do have other common pitfall charachters or phrases in strings, like &, ;, /, , , %, *. It doesn't seem like any of these need to be escaped, but I could be missing something. – user3517167 Jul 13 '23 at 20:46
  • What is your MySQL version? – Paul T. Jul 14 '23 at 02:38

0 Answers0