Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42220

Multiple And/Or Conditions On Select

$
0
0
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:

SQL Code:
  1. SELECT HSO.OrderID
  2. FROM HardwareStatus_Open HSO
  3. LEFT JOIN Orders_Open OO
  4. ON OO.OrderID = HSO.OrderID
  5. 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?

Viewing all articles
Browse latest Browse all 42220

Trending Articles