I have two tables Orders_Open and HardwareStatus_Open which are linked via the OrderID field. The HardwareStatus table indicates if an order requires hardware to be ordered, whether hardware is being supplied for the order and if those conditions have been met. I can get a list of orders that with an unmet requirement using the following query:
The join is there because I want to filter on the Salesperson field within the Orders_Open table. This is where I'm running into difficulties. I've tried putting AND OO.Salesperson = 'applicablename' in various places (inside and outside of the parentheses, on both sides of the OR, etc) but have yet to come up with a query that provides the correct results.
What would be the proper way to go about adding a second filter to this query?
SQL Code:
SELECT HSO.OrderID FROM HardwareStatus_Open HSO LEFT JOIN Orders_Open OO ON OO.OrderID = HSO.OrderID WHERE (HSO.NeedsOrdered = 1 AND HSO.HasOrdered = 0) OR (HSO.NeedsSupplied = 1 AND HSO.HasSupplied = 0)
The join is there because I want to filter on the Salesperson field within the Orders_Open table. This is where I'm running into difficulties. I've tried putting AND OO.Salesperson = 'applicablename' in various places (inside and outside of the parentheses, on both sides of the OR, etc) but have yet to come up with a query that provides the correct results.
What would be the proper way to go about adding a second filter to this query?