Getting too many rows back for this one.It should only be 2 rows.Here's the problem table structure:CREATE TABLE [dbo].[ImportAlertTrackingNumbers] (ImportAlertTrackNumID INT IDENTITY(1,1) CONSTRAINT PK_ImportAlertTrackingNumbers PRIMARY KEY NOT NULL,ImportAlertID INT NOT NULL CONSTRAINT FK_ImportAlertID_ImportAlertTrackingNumbers FOREIGN KEY (ImportAlertID) REFERENCES ImportAlert (ImportAlertID),InvImportAlertIDINT NULL
The InvImportAlertID is populated by dbo.inv.ImportAlertIDAnd the ImportAlertID by the contraint above (ImportAlert)Currently, the table ImportAlertTrackingNumbers has this:1 2 12 2 13 2 14 2 15 2 16 2 17 3 18 3 19 3 1The dbo.inv table has the ImportAlertID as I said And populates the third column and can have namy entries.There are only 2 distinct entries above for the second column.The table ImportAlert has only the one entry and only one ImportAlertIDThis is just bringing back too many rows...FROM ImportAlert aINNER JOIN ImportAlertTrackingNumbers itn ON a.ImportAlertID = itn.InvImportAlertID --AND inv.ImportAlertID = a.ImportAlertID--INNER JOIN ImportAlertTrackingNumbers itn ON --inv.ImportAlertID = itn.InvImportAlertID--itn.ImportAlertID = a.ImportAlertID INNER JOIN invoicenotadvanced inv ON a.ImportAlertID = inv.ImportAlertIDAND inv.ImportAlertID = itn.InvImportAlertID
Need some suggestions here,Thanks,Zath