#1064 - 您的SQL语法有错误。为什么?

时间:2014-11-24 10:44:17

标签: mysql

我正在尝试运行以下查询,但它给了我这个错误:

Error
SQL query:

/* Then insert some posts for testing: */ INSERT INTO posts( title, body, created ) 
VALUES (

’The title’, ’This IS the post body.’, NOW( )
);

MySQL said: Documentation

#1064 - 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 'title’, ’This is the post body.’, NOW())' at line 3 

这是代码,

 /* First, create our posts table: */
    CREATE TABLE posts (
    id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    title VARCHAR(50),
    body TEXT,
    created DATETIME DEFAULT NULL,
    modified DATETIME DEFAULT NULL
    );

    /* Then insert some posts for testing: */
    INSERT INTO posts (title,body,created)
    VALUES (’The title’, ’This is the post body.’, NOW());
    INSERT INTO posts (title,body,created)
    VALUES (’A title once again’, ’And the post body follows.’, NOW());
    INSERT INTO posts (title,body,created)
    VALUES (’Title strikes back’, ’This is really exciting! Not.’, NOW());

1 个答案:

答案 0 :(得分:2)

您没有在字符串中使用正确的撇号:

INSERT INTO posts( title, body, created ) 
VALUES (
'The title', 'This IS the post body.', NOW( )
);

您使用代替'。我假设你使用一些wordprocessor(如Word,LibreOffice等)编辑了文件。只需使用普通的旧文本编辑器(如Notepad,Vi等)。