join question
Posted: Sun Jan 14, 2007 11:21 pm
I'm working on an employee schedule display. I suck at join statements, I just can't get my head around it. I've been basically avoiding them.
Now it seems I can't any longer.
I have a table where I store the jobs
In an other table I have the assigned employees. It's not always just one employee. It could be any number of them. That's the reason it's a separate table.
My problem is that the employee (or employees) assigned to the jobs are outside of the jobs table completely.
Each employee can log in and check their own schedule and if they're assigned to a location with somebody else they have that information as well. Also, normally an employee would have 4-6 jobs for one day. job_date is a datetime in a 0000-00-00 00:00:00 format with the specific appointment date and time.
I need to join select job_id, customer_id, address_id and job_date where employee_id = $userId and also where job_date is between $jobLowDate and $jobHighDate and order it by job_date.
Thanks for your help.
Now it seems I can't any longer.
I have a table where I store the jobs
Code: Select all
====
jobs
====
job_id
customer_id
address_id
job_dateCode: Select all
=============
jobs_employee
=============
assign_id
job_id
employee_idEach employee can log in and check their own schedule and if they're assigned to a location with somebody else they have that information as well. Also, normally an employee would have 4-6 jobs for one day. job_date is a datetime in a 0000-00-00 00:00:00 format with the specific appointment date and time.
I need to join select job_id, customer_id, address_id and job_date where employee_id = $userId and also where job_date is between $jobLowDate and $jobHighDate and order it by job_date.
Thanks for your help.