I have a SQL statement that joins 5 tables but I think I must be joining them incorrectly. I have an asp.net form that allows input via check boxes and drop down lists so I’m building the SQL inside code based on the UI.
The criteria for the search will include fields from 3 different tables. The error I’m getting is
The multi-part identifier “openingReq.bgChk” could not be bound.
I feel like my joins must be the issue, but I’m not sure how I should change them to make this work.
Here’s the SQL statement
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'
I’m looking through your query and I can’t find a join to the
OPENINGREQtable.That would explain why SQL can’t bind it!