Let me preface this by stating that I'm new to SQL queries, and am learning on the fly. This type of question has been asked and answered multiple times, but I think my lack of expertise is keeping my from applying it properly to my environment.
I have a system with sales data kept in two separate SQL tables; salestable contains the status of the sales orders, while salesline has the detailed information from each order. 'SalesID' is common to both tables.
I need a query that will give the line item detail for every Sales Order with a particular status. I don't need to filter the results in the query (I can return all the columns), as we can do that afterward in Excel if need be.
dbo.SalesTable contains the SalesID, CustomerName, PurchaseOrderRef, and most importantly, SalesStatus (gives the status of the order as picked, packed for shipping, shipped, etc.).
dbo.SalesLines contains the SalesID, CustomerName (called CustAccount), ItemID, ShippingDateRequested, and ShippingDateConfirmed.
My query needs to return all information above for each order (identified by SalesID) that has a SalesStatus of 1 or 3.
I assume that this requires a join of some sort, but I'm struggling a bit with the syntax. Any help would be appreciated!