SQL Query Syntax Error - Spaces in Field Names

前端 未结 5 623
囚心锁ツ
囚心锁ツ 2021-02-08 13:49

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          


        
5条回答
  •  北恋
    北恋 (楼主)
    2021-02-08 13:59

    That depends on the database engine you're using.
    For SQL Server, you have to put the field names in brackets: [ ]

    SELECT * FROM [OV2 BAS] AS bas 
    INNER JOIN [OV2 RefID] AS ids ON bas.[Ref ID] = ids.[Ref ID]
    WHERE ids.ENUM_H = 'TDischarge';
    

提交回复
热议问题