I'm getting a Cartesian Product on the query below.
I'm getting 42 records and should be getting 3.
There are 14 extra's for that job... 42/3 = 14.
This is the part of the statement that returns the Cartesian Product.
- LEFT JOIN extra ex ON (ex.JOB_ID = j.JOB_ID)
See attached ERD
j.DSCR 'Job Name',
c.CostCode 'Cost Code',
e.EMPID 'Emp ID',
FROM labor l
LEFT JOIN emp e ON (e.EMP_ID = l.EMP_ID)
LEFT JOIN job j ON (j.JOB_ID = l.JOB_ID)
LEFT JOIN extra ex ON (ex.JOB_ID = j.JOB_ID)
LEFT JOIN ccode c ON (c.EXTRA_ID = ex.EXTRA_ID)
WHERE DATE_WORK = '2014-11-3'
AND l.DELETED = 'N'
AND j.JOB_ID = 37014; ERDTheEdgeLaborEntry.jpg
Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.