Clay
Clay

Reputation: 41

SQL(MS Access) syntax

Trying to find all these that are not in warehouse number 3 and unit price less than 100. Whats wrong with my code?

select part_number,
           part_description,
           Units_on_Hand,
           Unit_price,
           Warehouse_number
from part
where unit_price >= 100
and not in warehouse_number = 3;

Upvotes: 0

Views: 46

Answers (2)

Nick
Nick

Reputation: 38

SELECT part_number, part_description, Units_on_Hand, Unit_price, Warehouse_number 
FROM part 
Where unit_price >= 100 AND warehouse_number NOT IN (3);

Upvotes: -1

Gordon Linoff
Gordon Linoff

Reputation: 1269463

The problem is not in. You can do:

where unit_price >= 100 and
      not (warehouse_number = 3);

Or:

where unit_price >= 100 and
      warehouse_number not in (3);

Or:

where unit_price >= 100 and
      warehouse_number <> 3;

These are all equivalent. The last would be the more "typical" way to write this for 1 warehouse. The second would be the more typical way if there was more than one warehouse.

Upvotes: 2

Related Questions