D.E.N.N.I.S.
Registered User.
- Local time
- Today, 08:15
- Joined
- May 11, 2016
- Messages
- 12
I'm very new to SQL and I am having a heck of a time figuring out how to design this query. qryRackZeroOHB references two tables: Sizing and tblRackZeroOHBReviewed. This query will run daily and append into tblRackZeroOHBReviewed once the user enters the relevant information into the [Action] field.
I want the query parameters to cross reference the [Part Number] field between each table to exclude any records that match between Sizing and tblRackZeroOHBReviewed AND a DateDiff(d,now(),tblRackZeroOHBReviewed.[Review Date])>365. I also want to include records that do not have a [Part Number] match. I have no idea where to begin as I'm unfamiliar with inner/outer joins and unions. My current SQL has a syntax error.
My additional query parameters are in my current SQL statement below.
SELECT Sizing.[Part Number], Sizing.Ohb, Sizing.Trans, Sizing.Location, Sizing.[Curr Alpha], Sizing.[Curr Cs1], Sizing.[Curr Cs2], Sizing.[Curr Max Qty], Sizing.[Sugg Alpha], Sizing.[Sugg Cs1], Sizing.[Sugg Cs2], Sizing.[Sugg Max Qty], Sizing.Weight, Sizing.[Order Qty], Sizing.[Order Point Qty], Now() AS [Review Date], fOSUserName() AS [Reviewed By], "" AS [Action], "" AS [Additional Notes]
FROM Sizing, tblRackZeroOHBReviewed
LEFT OUTER JOIN tblRackZeroOHBReviewed
ON Sizing.[Part Number] = tblRackZeroOHBReviewed.[Part Number]
WHERE (((Sizing.Ohb)=0) AND ((Sizing.[Curr Alpha])="XS" Or (Sizing.[Curr Alpha])="XP" Or (Sizing.[Curr Alpha])="XT" Or (Sizing.[Curr Alpha])="XL" Or (Sizing.[Curr Alpha])="XV" Or (Sizing.[Curr Alpha])="HS") AND ((Sizing.[Curr Cs1])<>[Sizing].[Sugg Max Qty]) AND ((Sizing.[Sugg Alpha])<>"BN")) AND DateDiff(d,now(),tblRackZeroOHBReviewed.[Review Date])>365
ORDER BY Sizing.Trans DESC;
Any help would be much appreciated!
I want the query parameters to cross reference the [Part Number] field between each table to exclude any records that match between Sizing and tblRackZeroOHBReviewed AND a DateDiff(d,now(),tblRackZeroOHBReviewed.[Review Date])>365. I also want to include records that do not have a [Part Number] match. I have no idea where to begin as I'm unfamiliar with inner/outer joins and unions. My current SQL has a syntax error.
My additional query parameters are in my current SQL statement below.
SELECT Sizing.[Part Number], Sizing.Ohb, Sizing.Trans, Sizing.Location, Sizing.[Curr Alpha], Sizing.[Curr Cs1], Sizing.[Curr Cs2], Sizing.[Curr Max Qty], Sizing.[Sugg Alpha], Sizing.[Sugg Cs1], Sizing.[Sugg Cs2], Sizing.[Sugg Max Qty], Sizing.Weight, Sizing.[Order Qty], Sizing.[Order Point Qty], Now() AS [Review Date], fOSUserName() AS [Reviewed By], "" AS [Action], "" AS [Additional Notes]
FROM Sizing, tblRackZeroOHBReviewed
LEFT OUTER JOIN tblRackZeroOHBReviewed
ON Sizing.[Part Number] = tblRackZeroOHBReviewed.[Part Number]
WHERE (((Sizing.Ohb)=0) AND ((Sizing.[Curr Alpha])="XS" Or (Sizing.[Curr Alpha])="XP" Or (Sizing.[Curr Alpha])="XT" Or (Sizing.[Curr Alpha])="XL" Or (Sizing.[Curr Alpha])="XV" Or (Sizing.[Curr Alpha])="HS") AND ((Sizing.[Curr Cs1])<>[Sizing].[Sugg Max Qty]) AND ((Sizing.[Sugg Alpha])<>"BN")) AND DateDiff(d,now(),tblRackZeroOHBReviewed.[Review Date])>365
ORDER BY Sizing.Trans DESC;
Any help would be much appreciated!
Last edited: