当查询已在双引号内时,如何在oracle中使用空格来寻址列名?

时间:2012-09-25 07:31:49

标签: sql oracle

我有一个这样的查询,它已经是双引号。

result = db.Query("SELECT ACTUAL_N_WELLS, TARGET_N_WELLS, YTD ACTUAL AS YTD_ACTUAL, 
YTD BUDGET AS YTD_BUDGET, (CONVERT(DATETIME,PERIOD,112)) AS DATES 
FROM DASH_GL_DRILLING_PERF
 WHERE ASSET_NAME='Bab & Gas Asset' 
AND (  to_date(DASH_GL_DRILLING_PERF.PERIOD,'yyyy/mm/dd') > 
(SELECT add_months(max(to_date(DASH_GL_DRILLING_PERF.PERIOD,'yyyy/mm/dd')),-3) 
from DASH_GL_DRILLING_PERF))");

在“YTD ACTUAL”和“YTD BUDGET”列中有空格,但由于查询已在双引号内,我该如何编写列名?在这种情况下如何逃避双引号?

1 个答案:

答案 0 :(得分:4)

如果您对此使用C#JavaPHP,请使用反斜杠\

转义双引号
result = db.Query("SELECT ACTUAL_N_WELLS, TARGET_N_WELLS, \"YTD ACTUAL\" AS YTD_ACTUAL....");