2

This Question/Answer seems close to mine, but I think I have a different problem.

Here's my query:

SELECT
PL.PlantName AS 'Plant Name',
M.MachineNumber AS 'Line',
P.Type AS 'Record Type',
P.Reason,
P.ActivityDate,
P.OrderNumber,
P.Bundle,
P.Quantity,
P.ItemLength,
P.Pattern,
P.PartOption,
P.InvCoil,
P.Footage,
P.Material,
P.ScrapCode,
P.EmployeeName,
P.LBperFt,
P.DelayCode,
P.DelayReason,
P.Duration,
P.CostPerLb,
P.ListId,
P.ListText
FROM dbo.Production P WITH (NOLOCK)
JOIN dbo.Plants PL WITH (NOLOCK) ON P.PartnerId = PL.PartnerId
JOIN dbo.Machines M WITH (NOLOCK) ON PL.Id = M.Machine_Maintenance_Plant_Maintenance
WHERE ActivityDate >= '2018-04-01' AND ActivityDate <= '2018-04-07' ORDER BY 'Plant Name';

Before I added the third table, the query was fine. After joining the third table, I'm getting 6 copies of each row returned.

Hannah Vernon
  • 70,928
  • 22
  • 177
  • 323
user9570789
  • 123
  • 4

1 Answers1

1

This means there is 1 to Many relationship on the third table. You either need to add more in your join to make it 1 to 1 or create a crosswalk table to do the same.

Holmes IV
  • 126
  • 2