毫无疑问,我在这里遗漏了一些非常简单的东西,但我就是看不到这个查询的问题,它产生了以下错误:
SQL query:
INSERT INTO ads(
ad_id, author, ad_date, category, title,
description, condition, price, fullname,
telephone, email, status, photo, photothumb
)
VALUES (
NULL , 'justal', '1225790938', 'Windsurf Boards',
'test', 'test', 'Excellent', '12', 'test',
'test', 'test', '', '', ''
);
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 ''ad_id', 'author',
'ad_date', 'category', 'title', 'description',
'condition', '' at line 1有一双清新的眼睛能发现问题吗?
谢谢,艾尔。
发布于 2008-11-04 09:56:32
您不应该在列名中使用反引号而不是单引号吗?
INSERT INTO ads( `ad_id`, `author`, `ad_date`, `category`, `title`, `description`, `condition`, `price`, `fullname`, `telephone`, `email`, `status`, `photo`, `photothumb` )
VALUES (
NULL , 'justal', '1225790938', 'Windsurf Boards', 'test', 'test', 'Excellent', '12', 'test', 'test', 'test', '', '', ''
);发布于 2008-11-04 10:19:55
条件可能是mysql关键字,不允许作为列名。
http://dev.mysql.com/doc/refman/5.1/en/declare-conditions.html
您绝对不需要‘或`
发布于 2008-11-04 09:56:53
单引号用于字符串文字。在MySQL中,默认情况下,字符串字面值也使用双引号,尽管这与标准SQL不兼容,您应该在代码中坚持使用单引号。
对于列名,您通常根本不会引用它们。如果你需要这样做--你不需要这样做--那就用反引号(`)给它们加引号,或者将它设置为严格的ANSI兼容模式(ANSI_QUOTES)并使用双引号。
https://stackoverflow.com/questions/261375
复制相似问题