1

我有一个连接 5 个表的 SQL 语句,但我认为我必须错误地连接它们。我有一个 asp.net 表单,它允许通过复选框和下拉列表进行输入,因此我正在基于 UI 构建 SQL 内部代码。

搜索条件将包括来自 3 个不同表的字段。我得到的错误是

无法绑定多部分标识符“openingReq.bgChk”。

我觉得我的加入一定是问题所在,但我不确定我应该如何更改它们以使其工作。

这是SQL语句

  SELECT COMPANY.NAME, 
       SITE.NAME, 
       OPENING.JOBTITLE, 
       ( OPENINGSCHED.WEEKLYHOURSLOW + '-' 
         + OPENINGSCHED.WEEKLYHOURSHIGH )                   AS weeklyHours, 
       ( OPENINGCOMP.WAGELOW & '-' & OPENINGCOMP.WAGEHIGH ) AS payRange 
FROM   COMPANY 
       INNER JOIN [SITE] 
               ON COMPANY.ORGID = SITE.ORGID 
       INNER JOIN OPENING 
               ON SITE.SITEID = OPENING.SITEID 
       INNER JOIN OPENINGSCHED 
               ON OPENING.OPENINGID = OPENINGSCHED.OPENINGID 
       INNER JOIN OPENINGCOMP 
               ON OPENINGSCHED.OPENINGID = OPENINGCOMP.OPENINGID 
WHERE  OPENING.JOBORWE = 'Job' 
       AND OPENING.OCCUPATIONCODE = 59 
       AND COMPANY.SECTORCODE = 202 
       AND OPENING.ONBUSROUTE = 1 
       AND ( OPENING.LANGCODE = 1 
              OR OPENING.LANGCODE = 7 
              OR OPENING.LANGCODE = 22 ) 
       AND OPENING.TIER = 1 
       AND OPENINGREQ.BGCHK = 1 
       AND OPENINGREQ.MINEXP = 'no minimum experience' 
       AND OPENINGREQ.MINED = 'no minimum education' 
4

4 回答 4

1

您的查询中没有名为“openingReq”的表或别名。

于 2012-10-16T14:16:22.487 回答
1

我正在查看您的查询,但找不到该OPENINGREQ表的连接。
这可以解释为什么 SQL 不能绑定它!

于 2012-10-16T14:16:24.547 回答
0

我在任何地方都看不到openingReqJOIN 中的表 - 但 WHERE 子句......

于 2012-10-16T14:17:18.873 回答
0

OPENINGREQ在您的上下文中不存在。将其替换为正确的表名或别名:

   AND OPENINGREQ.BGCHK = 1 
   AND OPENINGREQ.MINEXP = 'no minimum experience' 
   AND OPENINGREQ.MINED = 'no minimum education' 
于 2012-10-16T14:28:24.690 回答