【问题标题】:You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near at line 1",您的 SQL 语法有错误;检查与您的 MariaDB 服务器版本相对应的手册,以在第 1 行附近使用正确的语法",
【发布时间】:2019-05-31 08:16:38
【问题描述】:

我尝试使用 vscode 和 mysql 在 postman 上发帖

您的 SQL 语法有错误;查看与您的 MariaDB 服务器版本相对应的手册,以在第 1 行的“发布、流派、控制台、价格、摘要、视频链接、图像链接、图像链接、de”附近使用正确的语法

我在 vscode 中使用的

INSERT INTO games (Category_id, title, release, genre, console, price, 
                        summary, video_link, image_link, image2_link, developer, category) 
VALUES (?,?,?,?,?,?,?,?,?,?,?,?);

我在邮递员中使用的

{
    "Category_id": "3",
    "title": "Monster Hunter World",
    "release": "2018",
    "genre": "Actiom",
    "console": "PS4",
    "price": 69,
    "summary": "hunting",
    "video_link": "youtube.com",
    "image_link": "image1",
    "image2_link": "image2",
    "developer": "Capcom",
    "category": "new"
}

【问题讨论】:

  • near release 表示紧接在列名release 之前 的语法问题。您确定正是您的代码中的内容吗?之前的列之后是否缺少逗号?

标签: python mysql visual-studio-code syntax-error postman


【解决方案1】:

release 是一个reserved word in MySQL。如果您打算将它作为列名,则需要对其进行转义:

INSERT INTO games (Category_id, 
                   title, 
                   `release`, -- Here, using the `s 
                   genre, 
                   console,
                   price, 
                   summary, 
                   video_link, 
                   image_link, 
                   image2_link, 
                   developer, 
                   category) 
VALUES (?,?,?,?,?,?,?,?,?,?,?,?);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-03-04
    • 2013-11-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多