简体   繁体   中英

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;

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM