I might have a problem with my SQL query. In this query I'm combining 4 different tables.
- I have a table
courseswhere general information is stored (course_number,course_title). - I have a table
employeeswhere general information of employees isstored (empname, and ajob_id). - A employee has a job. A employee needs to take courses. It depends on the job which courses he has to take. This info is stored in the table
job_course(with thejob_idand thecourse_id). - If a employee completed a course it is stored in the table
emp_courses(with thee_idand thecourse_id)
Now I want to search a certain course - when the user presses the search button he should get two different results.
- The first one: here you can see which employee already took this course (this query works so far)
- the second one: here you can see which employee still needs to take the course. So i need to check which job the employee has and if he needs to make that course . and also i just want to have the ones that are not completed yet. And that's the query that is not working
Here it is:
OpenDb_Open("select course_number,course_title, empname from course
INNER JOIN (job_course INNER JOIN (employee INNER JOIN emp_course
ON emp_course.e_id<>employee.e_id) ON job_course.job_id=employee.job_id)
ON course.course_id=job_course.course_id
where course_number like '" + coursenumber + "'");
Can someone please help me with this?
where course_number like @coursenumberand add a parameter called@coursenumber