SQL Server提供无效的列名称

时间:2014-03-06 02:12:54

标签: sql-server

使用以下SQL表达式但我收到错误:

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 server认为查询参数'companyID'和“processType”是列名???

提示:英语相对较差,希望你能理解;)谢谢

1 个答案:

答案 0 :(得分:1)

试试这个......

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'