tags:

views:

67

answers:

5

I seem to be going wrong somewhere in this INSERT query. Can someone tell me how to make this work?

Thanks.

INSERT INTO tablename ('score', 'coins-earned', 'bonus-used', 'topmultiplier', 'highscore', 'currentposition', 'super', 'star', 'color') 
VALUES ('1', '2', 'TRUE', '3', 'TRUE', '4', '5', '6', '7') 
A: 

Then Syntax itself is ok.

Please add the table description, there must be an error regarding the values you want to put into the table (maybe numeric and you want to insert "TRUE").

Björn
+1  A: 

Please provide the table structure.

I guess 'score' is numeric and you are trying to insert a string and so is the case with many other columns.

codaddict
A: 

i guess the numbers are numeric values in the table design, so you won't need the '' - and if the column "bonus-used" is a bit/bool column use 1/0 and not 'true'

so

values (1,2,1,3,1,4,5,6,7)

karlis
+7  A: 

You're putting column names in quotes, and hyphens are probably invalid in column names. In MS SQL, this is valid:

INSERT INTO tablename (score, [coins-earned], [bonus-used], 
    topmultiplier, highscore, currentposition, super, star, color) 
VALUES ('1', '2', 'TRUE', '3', 'TRUE', '4', '5', '6', '7') 

That also assumes that all the columns are char or varchar, which they're probably not. Numeric and boolean columns don't want quotes either, so it's possible you'll end up with something like this:

INSERT INTO tablename (score, [coins-earned], [bonus-used], 
    topmultiplier, highscore, currentposition, super, star, color) 
VALUES (1, 2, TRUE, 3, TRUE, 4, '5', '6', '7') 
egrunin
A: 

Try to replace the single quotes from the column names:

INSERT INTO tablename
  (`score`, `coins-earned`, `bonus-used`, `topmultiplier`,
   `highscore`, `currentposition`, `super`, `star`, `color`) 
VALUES ('1', '2', 'TRUE', '3', 'TRUE', '4', '5', '6', '7') 
Peter Lang