Microsoft Access不喜欢SQL查询中的表字段名称 [英] Microsoft Access does not like a table field name in a SQL Query

查看:74
本文介绍了Microsoft Access不喜欢SQL查询中的表字段名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在Microsoft Access 2010中运行以下SQL查询,但出现错误(INSERT INTO语句中的语法错误),如果我将该字段重命名为"Level1",它将突出显示"Level"字段作品.问题是我无法重命名该字段,因为我在PHP中有几个SQL查询依赖于字段名称"Level".有关为什么它将引发错误的任何想法.

I have the following SQL query that I am trying to run inside Microsoft Access 2010 and I get an error( Syntax error in INSERT INTO statement) then it highlights the field "Level" if I rename the field to "Level1" it works. The problem is that I can't rename the field because I have several SQL queries in PHP that I rely on the field name "Level" Any ideas of why it would throw an error.

运行查询的原因是使用链接表从外部ODBC sqlite数据库复制数据.我确实有其他几种以这种方式工作的INSERT INTO查询.如果还有其他方法,请告诉我.我在使用DoCmd.RunSQL的某些VB代码中进行查询

The reason I am running the query is to copy data from an external ODBC sqlite database using linked tables. I do have several other INSERT INTO queries working this way. If there is another way please let me know. I have the query in some VB code that I use DoCmd.RunSQL

INSERT INTO MinorStats1 ( PlayerID,YearNumber,TeamID,Level,B_PA,B_AB,B_Hits,B_Doubles,B_Triples,B_HR,B_RBI,B_BB,B_K,B_TB,B_AVG,B_SLG,B_OPS,B_OBP,B_FPCT,B_SB,B_CS,P_Wins,P_Losses,P_Saves,P_GS,P_OutsPitched,P_BF,P_Hits,P_HR,P_BB,P_K,P_ER,P_ERA)SELECT PlayerID,YearNumber,TeamID,Level,B_PA,B_AB,B_Hits,B_Doubles,B_Triples,B_HR,B_RBI,B_BB,B_K,B_TB,B_AVG,B_SLG,B_OPS,B_OBP,B_FPCT,B_SB,B_CS,P_Wins,P_Losses,P_Saves,P_GS,P_OutsPitched,P_BF,P_Hits,P_HR,P_BB,P_K,P_ER,P_ERA FROM MinorStats

推荐答案

level括在方括号中,如下所示:

Enclose level in square brackets as follows:

INSERT INTO MinorStats1 ( PlayerID,YearNumber,TeamID,[Level],B_PA,B_AB,B_Hits,B_Doubles,B_Triples,B_HR,B_RBI,B_BB,B_K,B_TB,B_AVG,B_SLG,B_OPS,B_OBP,B_FPCT,B_SB,B_CS,P_Wins,P_Losses,P_Saves,P_GS,P_OutsPitched,P_BF,P_Hits,P_HR,P_BB,P_K,P_ER,P_ERA)SELECT PlayerID,YearNumber,TeamID,[Level],B_PA,B_AB,B_Hits,B_Doubles,B_Triples,B_HR,B_RBI,B_BB,B_K,B_TB,B_AVG,B_SLG,B_OPS,B_OBP,B_FPCT,B_SB,B_CS,P_Wins,P_Losses,P_Saves,P_GS,P_OutsPitched,P_BF,P_Hits,P_HR,P_BB,P_K,P_ER,P_ERA FROM MinorStats

您需要执行此操作,因为level是Access中的保留字.有关保留字的完整列表,请参见 http://support.microsoft.com/kb/286335.

You need to do this because level is a reserved word in Access. For a complete list of reserved words, see http://support.microsoft.com/kb/286335.

这篇关于Microsoft Access不喜欢SQL查询中的表字段名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆