SQL Query Syntax Error - Spaces in Field Names

前端 未结 5 648
囚心锁ツ
囚心锁ツ 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 14:13

    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';
    

提交回复
热议问题