YuanXiaoxiaox 2022-03-31 17:10 采纳率: 100%
浏览 17
已结题

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);

  • 写回答

2条回答 默认 最新

  • DarkAthena ORACLE应用及数据库设计方案咨询师 2022-03-31 17:59
    关注
    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
      
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
    1人已打赏
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 4月10日
  • 已采纳回答 4月2日
  • 创建了问题 3月31日