0

Any ideas what I am doing wrong???

INSERT INTO LondonFixes ('id', 'Metal', 'AmPm', 'GBP', 'USD', 'EUR', 'Updated')VALUES(NULL, 'Gold', 'AM', '1055.91', '1646.00', '1272.03', '2012-06-19')

gives the following error:

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 ''id', 'Metal', 'AmPm', 'GBP', 'USD', 'EUR', 'Updated')VALUES(NULL, 'Gold', 'AM',' at line 1
1
  • 2
    you dont put quotes around the field names Commented Jun 19, 2012 at 2:13

2 Answers 2

3
 INSERT INTO LondonFixes (id, Meta, AmPm, GBP, USD, EUR, Updated)
 VALUES(NULL, 'Gold', 'AM', '1055.91', '1646.00', '1272.03', '2012-06-19')
Sign up to request clarification or add additional context in comments.

1 Comment

thank you. I had one error, tested a query in phpmyadmin, and it put backticks in there. I thought these were same as single quotes!!!
1

In MySQL, if you want to escape the column names, do not use single quote but instead use backtick.

INSERT INTO LondonFixes (`id`, `Metal`, `AmPm`, `GBP`, `USD`, `EUR`, `Updated`)
VALUES(NULL, 'Gold', 'AM', '1055.91', '1646.00', '1272.03', '2012-06-19')

2 Comments

Thanks, whats the difference between backtick vs single quote?
single quotes wraps a value while backtick escapes column name from reserved keywords.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.