-2

This is my code:

INSERT INTO aggregate_summary (sampler_label,aggregate_report_count,average,aggr
egate_report_median,aggregate_report_90%_line,aggregate_report_min,aggregate_rep
ort_max,aggregate_report_error%,aggregate_report_rate,aggregate_report_bandwidth
,aggregate_report_stddev) VALUES ("2010 sf1","238","276","16","224","2","3121","
0.0","55.04162812210916","249.6223837881591","766.5325177049589"), ("TOTAL","238
","276","16","224","2","3121","0.0","55.04162812210916","249.6223837881591","766
.5325177049589")

I get this error:

ERROR 1064 (42000): 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 'egate _report_median,"aggregate_report_90%_line",aggregate_report_min,aggregate_r' at line 1

Can someone help identify my problem thanks!

Bradders
  • 13
  • 5
Noor Chaudhry
  • 73
  • 1
  • 3
  • 7
  • 1
    Invalid identifers, use back-ticks around aggregate_report_90%_line etc. – jarlh Feb 09 '16 at 15:35
  • 1
    Judging for your question, your code has been justified to 80 columns with hard line breaks... – Álvaro González Feb 09 '16 at 15:37
  • 1
    `%` is the mathematical modulo operator, so your field names are totally illegal. – Marc B Feb 09 '16 at 15:38
  • You can't put whitespace (such as carriage returns) in the middle of an identifier. That makes it *two* identifiers, neither of which exist. Format your code to be human-readable and, as a bonus, the query parser would have an easier time understanding it. – David Feb 09 '16 at 15:41

2 Answers2

3

You must put any column names with spaces or punctuation (like percent signs) in backticks.

INSERT INTO foo ( `some column`, `other column %`, ...
Andy Lester
  • 91,102
  • 13
  • 100
  • 152
0

You need to define columns by putting them between ` character, because some of them are using reserved words for mysql like your column named average

INSERT INTO aggregate_summary (sampler_label,aggregate_report_count,`average`,`aggr
egate_report_median`,`aggregate_report_90%_line`,aggregate_report_min,aggregate_rep
ort_max,aggregate_report_error%,aggregate_report_rate,aggregate_report_bandwidth
,aggregate_report_stddev) VALUES ("2010 sf1","238","276","16","224","2","3121","
0.0","55.04162812210916","249.6223837881591","766.5325177049589"), ("TOTAL","238
","276","16","224","2","3121","0.0","55.04162812210916","249.6223837881591","766
.5325177049589")
JTC
  • 3,344
  • 3
  • 28
  • 46