ACCESS想查找一下customer里cust_id有但sales_detail表里cust_id无的数据,SQL写完运行无结果

SELECT customer.cust_name
FROM customer INNER JOIN sales_detail ON customer.cust_id = sales_detail.cust_id
WHERE customer.cust_id Not In (SELECT cust_id FROM sales_detail);

  1. not in
    SELECT customer.cust_name
    FROM customer 
    WHERE customer.cust_id Not In (SELECT cust_id FROM sales_detail);
    
  2. not exists
    SELECT customer.cust_name
    FROM customer 
    WHERE  Not exists (SELECT 1 FROM sales_detail where customer.cust_id=sales_detail.cust_id);
    
  3. left join
    SELECT distinct customer.cust_name
    FROM customer left JOIN sales_detail ON customer.cust_id = sales_detail.cust_id
    WHERE sales_detail.cust_id is null
    

SELECT cust_name FROM customer WHERE cust_id NOT IN (SELECT DISTINCT cust_id FROM sales_detail) tmp