MySQL 错误 #1064

发布于 2024-08-30 07:38:22 字数 1118 浏览 9 评论 0原文

我不断收到此错误:

MySQL 说:#1064 - 你有一个错误 在你的 SQL 语法中;检查手册 对应于您的 MySQL 服务器 正确使用语法的版本 靠近“插入” books.book(isbn10,isbn13,书名,版本,author_f_name,author_m_na' 在第 15 行

有这样的查询:

USE books;

DROP TABLE IF EXISTS book;


    CREATE TABLE `books`.`book`(
    `book_id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    `isbn10` VARCHAR(15) NOT NULL,
    `isbn13` VARCHAR(15) NOT NULL,
    `title` VARCHAR(50) NOT NULL,
    `edition` VARCHAR(50) NOT NULL,
    `author_f_name` VARCHAR(50) NOT NULL,
    `author_m_name` VARCHAR(50) NOT NULL,
    `author_l_name` VARCHAR(50) NOT NULL,
    `cond` ENUM('as new','very good','good','fair','poor') NOT NULL,
    `price` DECIMAL(8,2) NOT NULL,
    `genre` VARCHAR(50) NOT NULL,
    `quantity` INT NOT NULL)

    INSERT INTO books.book(isbn10,isbn13,title,edition,author_f_name,author_m_name,author_l_name,cond,price,genre,quantity)** 
    VALUES ('0136061699','978-0136061694','Software Engineering: Theory and Practice','4','Shari','Lawrence','Pfleeger','very good','50','Computing','2');

知道问题是什么吗?

I keep getting this error:

MySQL said: #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 'INSERT INTO
books.book(isbn10,isbn13,title,edition,author_f_name,author_m_na'
at line 15

with this query:

USE books;

DROP TABLE IF EXISTS book;


    CREATE TABLE `books`.`book`(
    `book_id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    `isbn10` VARCHAR(15) NOT NULL,
    `isbn13` VARCHAR(15) NOT NULL,
    `title` VARCHAR(50) NOT NULL,
    `edition` VARCHAR(50) NOT NULL,
    `author_f_name` VARCHAR(50) NOT NULL,
    `author_m_name` VARCHAR(50) NOT NULL,
    `author_l_name` VARCHAR(50) NOT NULL,
    `cond` ENUM('as new','very good','good','fair','poor') NOT NULL,
    `price` DECIMAL(8,2) NOT NULL,
    `genre` VARCHAR(50) NOT NULL,
    `quantity` INT NOT NULL)

    INSERT INTO books.book(isbn10,isbn13,title,edition,author_f_name,author_m_name,author_l_name,cond,price,genre,quantity)** 
    VALUES ('0136061699','978-0136061694','Software Engineering: Theory and Practice','4','Shari','Lawrence','Pfleeger','very good','50','Computing','2');

Any idea what the problem is?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

多情癖 2024-09-06 07:38:22

也许您忘记在这行代码后面添加“;”:

`quantity` INT NOT NULL)

maybe you forgot to add ";" after this line of code:

`quantity` INT NOT NULL)
难理解 2024-09-06 07:38:22

就我而言,我遇到了同样的错误,后来我知道“条件”是 mysql 保留关键字,我将其用作字段名称。

In my case I was having the same error and later I come to know that the 'condition' is mysql reserved keyword and I used that as field name.

土豪 2024-09-06 07:38:22

首先需要在quantity INT NOT NULL)后面添加分号(;)
然后从 ,genre,quantity)** 中删除 **。
要插入数字数据类型(如 int、decimal、float 等)的值,不需要添加单引号。

At first you need to add semi colon (;) after quantity INT NOT NULL)
then remove ** from ,genre,quantity)**.
to insert a value with numeric data type like int, decimal, float, etc you don't need to add single quote.

东京女 2024-09-06 07:38:22

有时,当您的表名称与数据库名称相似时,您应该使用反引号。所以而不是:

INSERT INTO books.book(field1, field2) VALUES ('value1', 'value2');

你应该有这个:

INSERT INTO `books`.`book`(`field1`, `field2`) VALUES ('value1', 'value2');

Sometimes when your table has a similar name to the database name you should use back tick. so instead of:

INSERT INTO books.book(field1, field2) VALUES ('value1', 'value2');

You should have this:

INSERT INTO `books`.`book`(`field1`, `field2`) VALUES ('value1', 'value2');
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文