2014-03-06 69 views
0

使用下面的SQL表達式,但我得到一個錯誤:SQL Server爲無效的列名

SELECT 
    t.*, va1.NAME_, 
    va2.NAME_ 
FROM 
    ACT_RU_TASK AS t 
INNER JOIN ACT_RU_EXECUTION AS e ON t.EXECUTION_ID_ = e.ID_ 
INNER JOIN ACT_RU_VARIABLE AS va1 ON va1.EXECUTION_ID_ = t.EXECUTION_ID_ 
INNER JOIN ACT_RU_VARIABLE AS va2 ON va2.EXECUTION_ID_ = t.EXECUTION_ID_ 
INNER JOIN ACT_RU_IDENTITYLINK AS idlink ON idlink.TASK_ID_ = t.ID_ 
WHERE 
    idlink.USER_ID_ = 3 
AND va1.NAME_ = "companyID" 
AND va2.NAME_ = "processType" 

錯誤信息來源:

[Err] 42S22 - [SQL Server]Invalid column name 'companyID'. 
42S22 - [SQL Server]Invalid column name 'processType'. 

爲什麼SQL服務器想查詢參數 'companyID' 和「processType」是列名?

提示:相對較差的英語,我希望你能理解;)謝謝

+1

雙引號字符串是現場/表名。你需要使用單引號,例如''companyID''。 –

回答

1

嘗試......在SQLSERVER

SELECT 
t.*, va1.NAME_, 
va2.NAME_ 
FROM ACT_RU_TASK t 
INNER JOIN ACT_RU_EXECUTION e ON t.EXECUTION_ID_ = e.ID_ 
INNER JOIN ACT_RU_VARIABLE va1 ON va1.EXECUTION_ID_ = t.EXECUTION_ID_ 
INNER JOIN ACT_RU_VARIABLE va2 ON va2.EXECUTION_ID_ = t.EXECUTION_ID_ 
INNER JOIN ACT_RU_IDENTITYLINK idlink ON idlink.TASK_ID_ = t.ID_ 
WHERE idlink.USER_ID_ = 3 
AND va1.NAME_ = 'companyID' 
AND va2.NAME_ = 'processType' 
+0

謝謝你,它的工作。 – Vito