You just need to join on the
jobcard_work_description
table and include
describtion
in your
select
clause (although I suspect it should be
description
) E.g.
select JC.jobcard_no,JC.vehicle_no,JC.vehicle_model,JC.[date], JS.staff_name,
JC.delivery_date,JC.total_days,VT.vehicle_name,JT.jobtype_name,
JWD.describtion
from jobcard_creation JC
left outer join vehicle_type VT on JC.department_id=vt.vehicle_id
left outer join Job_type JT on JT.jobtype_id=JC.job_type
left join jobcard_staff JS on JS.jobcard_id=JC.jobcard_id
left join jobcard_work_description JWD on JC.jobcard_id=JWD.jobcard_id
where JC.jobcard_id=@cardid and JC.[type]='N' and JS.type='N'
Couple of things to note:
- I've surrounded column names that are reserved words with square brackets e.g.
[type]
and
[date]
- I've used table aliases to make the select clause a bit more readable e.g. JC, JT, VT etc.
- Take note of the comment from Richard Deeming - NEVER use string concatenation to build a SQL query. See
@cardid
in my query above