为什么这个非常简单的 SQL 查询在 MS Access 中失败?

发布于 2024-11-13 09:55:59 字数 565 浏览 7 评论 0原文

我有一个查询,从所有权利来看都不应该失败,而且我一生都无法弄清楚为什么

INSERT INTO Grocery_Store_Prices(Store,Item,Brand,Price,Unit,Quantity,Note) 
VALUES("Kroger","Cheesy Poof","Cartman",0.51,"fart",15,"what is going on");

当我尝试运行查询时,我得到“INSERT INTO 语句中的语法错误”,并突出显示“注释”字段。如果我省略“注释”字段及其值,则查询可以正常工作。是否有一些明显的我遗漏的东西,或者这里是否隐藏着 Jet SQL 的怪癖???

它作用的表是: Grocery_Store_Prices

  • ID -- 自动编号主键
  • 商店 -- 文本
  • 日期 -- 日期/时间
  • 项目 -- 文本
  • 品牌 -- 文本
  • 价格 -- 货币
  • 单位 -- 文本
  • 数量 -- 数字(双)
  • 注释 -- 文本。

I have a query that by all rights should not possibly fail, and I can't for the life of me figure out why

INSERT INTO Grocery_Store_Prices(Store,Item,Brand,Price,Unit,Quantity,Note) 
VALUES("Kroger","Cheesy Poof","Cartman",0.51,"fart",15,"what is going on");

When I try to run the query I get "Syntax error in INSERT INTO statement" with the Note field highlighted. If I omit the Note field and its value, the query works fine. Is there something really obvious I'm missing, or is there an Jet SQL quirk buried here???

The table it's acting on is:
Grocery_Store_Prices

  • ID -- autonumber primary key
  • Store -- Text
  • Date -- Date/Time
  • Item -- Text
  • Brand -- Text
  • Price -- Currency
  • Unit -- Text
  • Quantity -- Number (double)
  • Note -- Text.

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

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

发布评论

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

评论(2

冷血 2024-11-20 09:55:59

“注释”是 Microsoft Access 中的保留字。您需要用方括号将其括起来:

INSERT INTO Grocery_Store_Prices(Store,Item,Brand,Price,Unit,Quantity,[Note])
VALUES("Kroger","Cheesy Poof","Cartman",0.51,"fart",15,"what the ____");

这里有有用的保留字列表:http://support.microsoft.com/kb/286335< /a>

有些人认为最好的做法是始终将字段名称括在方括号中,这样您就不必担心它。

祝你好运!

"Note" is a reserved word in Microsoft Access. You need to surround it with square brackets:

INSERT INTO Grocery_Store_Prices(Store,Item,Brand,Price,Unit,Quantity,[Note])
VALUES("Kroger","Cheesy Poof","Cartman",0.51,"fart",15,"what the ____");

Helpful list of reserved words here: http://support.microsoft.com/kb/286335

Some consider it best practice to always encase field names in square brackets, just so you don't have to worry about it.

Good luck!

Bonjour°[大白 2024-11-20 09:55:59

注意是保留字,因此请尝试重命名该列。

Note is a reserved word, so try renaming that column.

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