SQL 查询语法错误 - 字段名称中的空格 [英] SQL Query Syntax Error - Spaces in Field Names
问题描述
我的应用程序使用的数据库具有包含空格的字段名称.我相信这是我的问题的原因.这是一个典型的查询:
The database my application uses has field names containing spaces. I believe this to be the cause of my problem. Here is a typical query:
SELECT * FROM 'OV2 BAS' AS bas
INNER JOIN 'OV2 RefID' AS ids ON 'bas.Ref ID' = 'ids.Ref ID'
WHERE ids.ENUM_H = 'TDischarge';
如何处理字段名称中的空格?谢谢.
How do I deal with the spaces in the field names? Thanks.
其他信息
这是为了访问使用 MS Access 2007 (Microsoft.ACE.OLEDB.12.0) 制作的数据库.
This is to access a database made with MS Access 2007 (Microsoft.ACE.OLEDB.12.0).
推荐答案
我认为您不能在实际表名周围使用引号;只有您分配给它的名称.我会将表格括在括号中:[OV2 BAS]
I don't think you can use quotes around the actual table name; only the name you assign to it. I would wrap the table in brackets instead: [OV2 BAS]
您也不能在连接语法周围加上引号.试试这个:
You also can't put quotes around your joining syntax either. Try this instead:
SELECT * FROM [OV2 BAS] AS bas INNER JOIN [OV2 RefID] AS ids ON bas.[Ref ID] = ids.[Ref ID] WHERE ids.ENUM_H = 'TDischarge';
这篇关于SQL 查询语法错误 - 字段名称中的空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!