0

When attempting to run this query in Node.JS/Express using MySQL, I get an error.

Without the line "created DATETIME,\n" the code works perfectly. When including that line, or any variation of it (such as trying to attempt to put a default date of the current time), it also says the exact same error.

"You have an error in your SQL syntax; check the ... (redacted) ... for the right syntax to use near '' at line 4"

var create_elements = 
    "CREATE TABLE elements(\n" +
    "id          INT NOT NULL AUTO_INCREMENT,\n" +
    "googleID    VARCHAR(60),\n"  +
    "created     DATETIME,\n"
    "title       VARCHAR(300),\n" +
    "body        TEXT,\n"         +
    "type        ENUM('blog', 'issue'),\n" +
    "PRIMARY KEY (id)\n"          +
    ");";
1
  • 2
    You're missing a + after "created DATETIME,\n", is that a typo? Commented Aug 29, 2015 at 0:57

1 Answer 1

1

There is no plus sign after your new string snippet containing the DATETIME line, so the resulting string does not contain the remaining elements or closing parenthesis and is syntactically invalid.

Sign up to request clarification or add additional context in comments.

Comments

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.