-2

I created a table "Prices" with a column named after the current time. I am trying to enter 679.09 into the Prices table where the column name is 1460217349.29.

INSERT INTO Prices('1460217349.29') VALUES (678.09);

I looked at w3 schools and I think this is the right syntax but I am getting syntax error missing SELECT.Any advice? This seems pretty straight forward.

Edit: It appears that using a decimal number requires a backtick. I did not ask about backticks but that seems to be the answer.

Steve Scott
  • 1,441
  • 3
  • 20
  • 30
  • 1
    Possible duplicate of [When to use single quotes, double quotes, and backticks?](http://stackoverflow.com/questions/11321491/when-to-use-single-quotes-double-quotes-and-backticks) – Lukasz Szozda Apr 09 '16 at 16:22
  • 2
    Naming column like that is bad practice. Anyway wrap column name with backticks – Lukasz Szozda Apr 09 '16 at 16:22

1 Answers1

5

You have a very curious naming scheme for your columns. But the correct way to identify the column is to use backticks:

INSERT INTO Prices(`1460217349.29`)
    VALUES (678.09);

I strongly encourage you to change the name to something that doesn't require escaping. In fact, a number or time value seems much more like a value in a column than a column name.

EDIT:

The issue with your naming is that the column name includes a period. That is not allowed unless you escape the name. In addition, if you removed the period, then it would be a number, and that is not allowed.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
  • LOL. Your answer is right, of course, but it looks _so wrong_ due to that funny column name. I wonder when people will try to make up columns with backticks in their names. – PerlDuck Apr 09 '16 at 16:44
  • 1
    This is not strong encouragement. – Strawberry Apr 09 '16 at 16:44
  • Why do I need to use backticks? Is it because it is a number? It is not a keyword. Would it be better to make the column a date string? – Steve Scott Apr 09 '16 at 18:40